total_events function

Count total events