It is audit day at the caldera rim of Firewatch. Quin spreads the beacons records across the table and picks up a sharp pencil. Task: n isolated nodes are joined by m edges (some may be redundant). Print the minimum number of additional edges needed to make the graph connected. Input format: First line: n and m. Next m lines: u v. Output format: Print the number of extra edges needed. Constraints: 1 <= n <= 4000; 0 <= m <= 4000.
Example 1:
Example 2:
Example 3:
Constraints:
1 <= n <= 4000; 0 <= m <= 4000.
