1404 旅行问题


Submit solution

Points: 100
Time limit: 1.0s
Memory limit: 32M

Problem types
Allowed languages
C, C++, Java, Python

Description

某有名的群岛有N个岛屿,其中有些岛屿之间有桥(有的岛屿之间不止一座桥)可以相连,而有些岛屿之间是没有桥,则只能通过坐船来到达了。现在如果已经整个群岛的地图,请你求出最少坐船的次数。

Input

有多组测试数据。每组测试数据以N和M开头,其中N(1<=N<=100)表示岛屿个数,M(1<=M<=100)表示桥的数量,接下来M行每行有两个整数A,B(1<=A,B<=N),表示A岛屿和B岛屿有桥相连.

Output

对于每组数据输出最少坐船次数.

Sample

Input

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

Output

0
2

Source: hxm


Comments

There are no comments at the moment.