#Lutece2840. Fatdog Wants to Buy Games
Fatdog Wants to Buy Games
Migrated from Lutece 2840 Fatdog Wants to Buy Games
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
There are students in a game club. The number of different games they have played together does not add up to . In this club, every two students can be good friends in the following patterns.
- If student has played a game that is also had played by student , the two students and can become good friends.
- If student is one of 's friends, meanwhile students is also a good friend of 's, the two students and can become good friends.
Fatdog already knows which games each student has played. He wishes any two students in the club to be friends. He decides to buy some games as gifts for some of the students in the club. After he bought a game as a gift for student , in that case, we can assume that had played the game .
But Fatdog is so poor, so he wants to buy the minimum number of games to achieve his wish. Could you please help Fatdog calculate the minimum number of games he needs to buy?
Input
The first line contains three integers $n,m,k\ (2\le n\le 10^5,1\le m\le 10^5,0\le k\le 10^5)$.
For the following lines, each line contains two integers , representing that before Fatdog buys any game, the -th student had played the -th game.
Output
One integer, which stands for the minimum number of games Fatdog needs to buy.
Samples
3 3 2
2 3
3 1
2
Resources
The 18th UESTC Programming Contest Preliminary