Why Did the Cow Cross the Road (Bronze)#10532

Why Did the Cow Cross the Road (Bronze)

1 second
128 megabytes
Very easy

While the age-old question of why chickens cross roads has been studied extensively by the scientific community, surprisingly little has been published about the related question of why cows cross roads. Farmer John, well aware of the importance of this issue, is thrilled when a local university contacts him to ask for his assistance with a scientific study of why cows cross roads. He eagerly volunteers to help.

As part of the study, Farmer John has been asked to document the number of times each of his cows crosses the road. He carefully records the locations of his cows, making a series of observations over the course of a single day. Each observation records the ID of a cow (an integer in the range , since Farmer John has cows), as well as the side of the road on which the cow is located.

Based on Farmer John's observations, please help him count the total number of confirmed crossings. A confirmed crossing occurs when two consecutive observations of the same cow place her on different sides of the road.

Input

The first line contains the number of observations n~(n \le 100). Each of the next lines contains one observation, consisting of a cow ID followed by its position, given as either zero or one (zero indicates one side of the road, and one indicates the other side).

Output

Print the total number of confirmed crossings.

Examples

In this example, cow crosses twice: she first appears on side , then later appears on side , and then later appears back on side . Cow definitely crosses once. Cows and do not appear to cross.

Example 1

Loading
Loading