Problem J
Just Enough Bridges
Chimera Ant is an intelligent and hard-working species.
There is a colony of
The ants have also built
Every morning, the
The bridges were built in such a way that it is possible for
the ants to go directly to all
The ants feel that they have built too many bridges. Thus they want to remove exactly one bridge, so that the above condition is still true.
Even though the Chimera Ants are very intelligent, they are not good with numbers. Please help the ants figure out how many different bridges they can remove.
Input
The first line of the input contains two integers
Each of the next
Output
The number of bridges satisfying the given conditions.
Sample Input 1 | Sample Output 1 |
---|---|
2 3 1 1 1 2 2 2 |
1 |