#abc147c. [abc147_c]HonestOrUnkind2
[abc147_c]HonestOrUnkind2
Problem Statement
There are people numbered to . Each of them is either an honest person whose testimonies are always correct or an unkind person whose testimonies may be correct or not.
Person gives testimonies. The -th testimony by Person is represented by two integers and . If , the testimony says Person is honest; if , it says Person is unkind.
How many honest persons can be among those people at most?
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the maximum possible number of honest persons among the people.
Sample Input 1
3
1
2 1
1
1 1
1
2 0
Sample Output 1
2
If Person and Person are honest and Person is unkind, we have two honest persons without inconsistencies, which is the maximum possible number of honest persons.
Sample Input 2
3
2
2 1
3 0
2
3 1
1 0
2
1 1
2 0
Sample Output 2
0
Assuming that one or more of them are honest immediately leads to a contradiction.
Sample Input 3
2
1
2 0
1
1 0
Sample Output 3
1