Counting no. of groups of people coming and standing in a line