Conditional Statements

No attempts yetTime limit1sMemory limit128 MB

Problem

Bonjol has a new task at work. He is handed Pascal code that controls a set of lights, and he has to make the code as short as possible while keeping its behavior exactly the same as before. The code consists only of conditional statements, and every line has this form.

if <variable> <comparison-operator> <comparison-value> then turnOn( <light-number> );
  • <variable> is a string of at most 255 lowercase English letters, the name of a Pascal integer variable.
  • <comparison-operator> is <, >, or =.
  • <comparison-value> is a 32-bit integer constant that the variable is compared against.
  • <light-number> is a 32-bit integer constant, the number of the light that must be turned on when the condition <variable> <comparison-operator> <comparison-value> holds. Turning on a light that is already on does nothing.

A variable can hold any integer. Two programs behave exactly the same when, for every assignment of integers to the variables, they turn on the same set of lights.

The only edit Bonjol may make is deleting a whole line. He wants to delete as many lines as he can while the program keeps behaving exactly like the original. Compute the largest number of lines he can delete.

Input

The input contains several test cases. The first line of a test case holds the number of code lines nn (1n5001 \le n \le 500). Each of the next nn lines holds one conditional statement. Inside a statement there is exactly one space after if, after <variable>, after <comparison-operator>, after <comparison-value>, after then, after turnOn(, and after <light-number>. The input ends with a line containing 0, which is not a test case.

Output

For each test case print the largest number of lines Bonjol can delete, one per line, in the order the test cases are given.