Problem D
Neðanjarðargöng
Languages
en
is
Since the underground tunnel between Veröld and Háskólatorg was such a hit the University of Iceland decided to connect all university buildings in a similar manner. Sometimes maintenance needs to be done on the tunnels so it is desirable to be able to get from any building to any other, even with an arbitrary tunnel closed. There are already some tunnels in place and now they need to see how they are doing. Can you determine the minimum number of tunnels to be added such that the above criterion is met?
Input
The first line of the input contains integers
Output
One line with a single integer, the minimum number of tunnels to add such that the above criterion is met.
Sample Input 1 | Sample Output 1 |
---|---|
6 5 1 2 3 2 2 5 4 5 6 5 |
2 |
Sample Input 2 | Sample Output 2 |
---|---|
3 3 1 2 2 3 3 1 |
0 |