#0001AE

z-if

In order to become z-moderator, a user has to satisfy a lot of requirements. Actually, mister little Z. made the list of the requirements such that it is impossible to satisfy all of them

Mister little Z gives you a questionnaire with N YES/NO questions. After he gets your answers, he looks at your answers, checking whether they satisfy the M rules he has come up with.

For example, if the questions are:

Q1: Are you tall
Q2: Do you like PC more than MAC
Q3: Do you like Windows more than Unix

Little Z's list of rules can look like:

if Q1 then Q2
if Q2 then not Q3
if not Q2 then Q1

This can be satisfied if you choose the following answers:
Q1 - YES
Q2 - YES
Q3 - NO

However, if Z's list of rules was the following:

if Q1 then Q2
if Q2 then Q3
if Q3 then not Q1
if not Q1 then not Q2
if not Q2 then Q1

Then it is impossible to satisfy the requirements!

The question for you is: What is the minimal number of questions that Z should delete from the list (and therefore all the rules that contain that question) so that the remaining set of rules can be satisfied?



InputFrom the first line of the standard input read one integer M, (1 <= M <= 100000). From each of the next M lines read one rule. The rule will be in the following format: "if (not) Q1 then (not) Q2". Where Q are strings (up to 20 characters consisting of the letters from the English alphabet and numbers, without spaces) representing the name of the question. The number of different questions will be <= 100000.


OutputTo the standard output write one integer, the minimal number of questions that Z has to delete so that the remaining set of rules can be satisfied


Input:
6
if green then not fat
if man then not green
if fat then not man
if not green then fat
if not man then green
if not fat then man

Output:
1


Input:
5
if green then not green
if not green then green
if man then green
if man then not man
if not man then man

Output:
2

Submit solution

Coming later

The grading service will be connected in a later migration step. You can inspect the task and your previous results now.