#ablc. [abl_c]Connect Cities

[abl_c]Connect Cities

Problem Statement

There are NN cities numbered 11 through NN, and MM bidirectional roads numbered 11 through MM. Road ii connects City AiA_i and City BiB_i.

Snuke can perform the following operation zero or more times:

  • Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities.

After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times).

What is the minimum number of roads he must build to achieve the goal?

Constraints

  • 2leqNleq100,0002 \\leq N \\leq 100,000
  • 1leqMleq100,0001 \\leq M \\leq 100,000
  • 1leqAi<BileqN1 \\leq A_i < B_i \\leq N
  • No two roads connect the same pair of cities.
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN MM A1A_1 B1B_1 :: AMA_M BMB_M

Output

Print the answer.


Sample Input 1

3 1
1 2

Sample Output 1

1

Initially, there are three cities, and there is a road between City 11 and City 22.

Snuke can achieve the goal by building one new road, for example, between City 11 and City 33. After that,

  • We can travel between 11 and 22 directly.
  • We can travel between 11 and 33 directly.
  • We can travel between 22 and 33 by following both roads (22 - 11 - 33).