#include <stdio.h>
#include <stdlib.h>
int n,m;
int father[],rank[];
int count; int find(int x)
{
if(father[x]==x) return x;
else return father[x]=find(father[x]);
}
void unit(int x,int y)
{
x=find(x);
y=find(y);
if(x==y) return; if(rank[x]<rank[y]){
father[x]=y;
count--;
}else{
father[y]=x;
if(rank[x]==rank[y]) rank[x]++;
count--;
}
}
int main()
{
while(scanf("%d",&n)==){
if(n==) break;
scanf("%d",&m);
count=n;
int i;
//初始化
for(i=;i<n;i++){
father[i]=i;
rank[i]=;
}
int x,y;
for(i=;i<m;i++){
scanf("%d%d",&x,&y);
unit(x-,y-);
}
printf("%d\n",count-);
}
return ;
}
05-20 22:13