#K53377. Minimum Bridges to Cross

    ID: 29518 Type: Default 1000ms 256MiB

Minimum Bridges to Cross

Minimum Bridges to Cross

Peter wants to visit all the islands connected by bridges. Given a connected graph with ( n ) islands and ( m ) bridges, Peter needs to cross the minimum number of bridges to visit every island. In any connected graph, the minimum number of bridges (or edges) that must be traversed to visit all islands is ( n - 1 ).

The graph details (i.e., the actual bridges between islands) are provided in the input for completeness, but the solution only depends on the total number of islands. Your task is to compute ( n - 1 ).

inputFormat

The input is read from standard input (stdin) and has the following format:

(n) (m) — two integers where (n) is the number of islands and (m) is the number of bridges.

This is followed by (m) lines, each containing two integers (u) and (v), representing a bridge connecting island (u) and island (v).

outputFormat

Output a single integer representing the minimum number of bridges Peter must cross to visit every island. The output should be sent to standard output (stdout).## sample

5 5
1 2
1 3
2 4
3 4
4 5
4