Lie

Accepts: 0
Submissions: 7
Time Limit: 4000/2000 MS (Java/Others)
Memory Limit: 131072/131072 K (Java/Others)
Problem Description
There are N students in a grade, each student belongs to only one class.Now all they standing in a row,but students in the same class are not necessarily going to stand together. Everyone will say a sentence like "Well,there are Ai my classmates stand on my left,as well as Bi my classmates on the right".But not everyone will tell the truth,the teacher also forgot their order of speech.Now the teacher want to know maximum number of people say without contradiction.
Input
There are multiple test cases, no more than 100 cases. In each test case, the first line contains a single integer N.$(1\leq N\leq 1000 )$ The following N lines specify the people. Each of them contains two integers Ai and Bi separated by single spaces.$(0\leq Ai,Bi\leq 1000 )$
Output
For each test case,output the answer in a line.
Sample Input
3
0 2
2 0
3 0
5
0 0
1 0
0 0
0 0
0 0
Sample Output
2
4