Baltic Olympiad in Informatics: 2003 Day 2, Problem 1
Chicago in the 1920s: a battlefield of gangsters.
If two gangsters have ever met each other, then they have become either true friends or mortal enemies. The gangsters live - and die - by the following code of ethics:
- A friend of my friend is also my friend.
- An enemy of my enemy is my friend.
Two gangsters are in the same gang if and only if they are friends.
Poor you are employed by the Chicago Police Department. You must calculate the maximal possible number of different gangs in Chicago based on what the Department knows about the relations between the individual gangsters.
Input Specification
The first line of the input gives the number
The following F p q
or E p q
, where F
, the line says that E
, then they are known enemies.
It can be assumed that the input is consistent - two gangsters cannot be both friends and enemies of each other.
Output Specification
The first and only line of the output must contain the maximal possible number of gangs.
Sample Input
6
4
E 1 4
F 3 5
F 4 6
E 1 2
Sample Output
3
Explanation for Sample
The
Comments