There are n computers numbered 1 to n and m cables, each joining two computers. Some cables are redundant: removing them does not change which computers can reach which. What is the largest number of cables you can remove so that every pair of computers that could reach each other before still can?
The first line has n and m. Each of the next m lines has two computers a and b. Cables may repeat and may join a computer to itself.
Print one integer: the largest number of cables that can be removed.
1 <= n <= 200000 0 <= m <= 200000
1000 ms256 MB
5 5 1 2 2 3 3 1 4 5 1 2
2
Computers form two groups, {1,2,3} and {4,5}. Keeping 2 + 1 = 3 cables is enough, so 5 - 3 = 2 can go.
4 3 1 2 2 3 3 4
0
Every cable is needed.