At JOI High School, a vote was held on a certain proposal, asking students to vote either "for" or "against." N students voted in order. Before voting, each student could know how the other students who had already voted had voted.
The i-th student (1 ≦ i ≦ N) voted "for" if the following condition was satisfied, and voted "against" otherwise.
Note that if Yi = 0, the student voted "for" regardless of the other students' votes, and if Yi = Xi + 1, the student voted "against" regardless of the other students' votes.
Given the information about each student's voting rule, write a program to find the number of students who voted "for."
The input is given from standard input in the following format.
N
X1 Y1
X2 Y2
:
XN YN
Output the number of students who voted "for" in one line to standard output.
4 0 1 1 0 1 1 3 3
2
The votes were cast in order by 4 students as follows.
There are 2 students who voted "for." Therefore, output 2.
5 0 0 1 1 2 3 3 1 4 3
4
10 0 0 1 2 1 1 1 0 3 1 2 3 1 1 5 3 8 4 7 2
4
Japan Information Olympiad Committee "Japan Information Olympiad 2nd Women's Division Finals Problem"