#t525. 团伙
团伙
The Gang
Problem Background
Special for beginners, ^_^
Problem Description
In a certain city there live people. Any two acquaintances are either friends or enemies, and they satisfy:
- A friend of my friend is my friend;
- An enemy of my enemy is my friend.
All people who are friends form a gang. Given pieces of information about these people — that two particular people are friends, or that two particular people are enemies — please write a program to compute the maximum possible number of gangs in this city.
Input Format
The first line contains and , with , .
The following lines each contain . is or . When , it means and are friends; when , it means and are enemies.
Output Format
One integer: the maximum possible number of gangs among these people.
Sample Input
6 4
1 1 4
0 3 5
0 4 6
1 1 2
Sample Output
3
Constraints
Time limit: 1s; memory limit: 1024 KiB for each test case.