Milk Measurement (Bronze)#10511

Milk Measurement (Bronze)

1 second
128 megabytes
Medium

Farmer John purchases three cows: Bessie, Elsie, and Mildred. Each cow initially produces gallons of milk per day. Since a cow's milk production may change over time, Farmer John takes periodic measurements over the next days and records them in a log book. Entries in his log look like this:

35 Bessie -2
14 Mildred +3

The first entry indicates that on day , Bessie's milk production was gallons lower than when it was last measured. The next entry indicates that on day , Mildred's milk production increased by gallons compared to her previous measurement.

Farmer John has enough time to make at most one measurement on any given day. Unfortunately, he is a bit disorganized and does not necessarily record his measurements in chronological order.

To keep his cows motivated, Farmer John proudly displays on the wall of his barn pictures of whichever cows currently have the highest milk production. If several cows are tied for the highest production, he displays all of their pictures. Determine the number of days on which Farmer John would have needed to change this display.

Input

The first line contains , the number of measurements Farmer John makes. Each of the next lines contains one measurement in the format described above. Each measurement specifies a day (an integer in the range ), the name of a cow, and the change in her milk production since it was last measured (a nonzero integer).

Each cow's milk production will always remain in the range .

Output

Print the number of days (an integer in the range ) on which Farmer John needs to change his motivational display.

Examples

Initially, all three cows produce gallons of milk per day. On day , Bessie's milk production increases to , making her the unique cow with the highest production and causing Farmer John to change his display. On day , Elsie's milk production decreases to , but Bessie remains the sole leader, so the display does not change. On day , Mildred takes the lead, causing another change to the display. Finally, on day , Mildred ties with Bessie for the highest production, causing the display to change once again.

Example 1

Loading
Loading