National Olympiad in Informatics, China, 2001
The animal kingdom contains three species of animals A, B, and C. The food chain of these animals forms an interesting loop shape, where A eats B, B eats C, and C eats A.
There are
An individual uses two methods to describe the relationship between the animals in their food chain:
- The first method is using the format
1 X Y
, indicating that and belong to the same species. - The second method is using the format
2 X Y
, indicating that eats .
Regarding these
- If the current statement conflicts with an already stated true statement, then the current statement is a lie.
- If the current statement has
or greater than , then the current statement is a lie. - If the current statement indicates that
eats , then the statement is a lie.
Your task is, given a number
Input Specification
The first line of input contains two integers
The next
Output Specification
The output should consist of a single integer - the number of false statements.
Sample Input
100 7
1 101 1
2 1 2
2 2 3
2 3 3
1 1 3
2 3 1
1 5 5
Sample Output
3
Explanation
For the 7 statements:
1 101 1
is a lie.2 1 2
is true.2 2 3
is true.2 3 3
is a lie.1 1 3
is a lie.2 3 1
is true.1 5 5
is true.
Problem translated to English by .
Comments