#d1805. Cow and Snacks
Cow and Snacks
Cow and Snacks
Problem Description
The farm is hosting a party!
There are kinds of snacks, numbered from , each snack having exactly one portion. There are guests coming, and each guest has two favorite flavors.
The farmer can arrange the guests to come in some order, one by one.
When a guest arrives, he eats all the snacks of his favorite flavors. If there is none of his favorite flavor left, he leaves sadly.
How should the guests be ordered so that the number of sad guests is minimized? Output the minimum possible number of sad guests.
Input Format
The first line contains two integers (, ), the number of snacks and the number of guests respectively.
Each of the next lines contains two integers (, ), the numbers of the two favorite snacks of guest .
Output Format
Output one integer: the minimum number of sad guests.
Sample Input 1
5 4
1 2
4 3
1 4
3 4
Sample Output 1
1
Sample Input 2
6 5
2 3
2 1
3 4
6 5
4 5
Sample Output 2
0
Sample Explanation
In the first sample, the guests can be ordered as . Guest eats snacks and ; then guest eats snack ; guest eats snack ; guest finds no favorite snack left and leaves sadly, so the answer is .
In the second sample, ordering the guests as makes no guest sad.