AC:
#include<iostream>
#include<cstring>
using namespace std;
int father[1000];
int find(int x){
while(father[x]!=-1) x=father[x];
return x;
}
void Union(int a,int b){
int fa=find(a),fb=find(b);
if(fa!=fb){
father[fa]=fb;
}
}
int main() {
int n,m;
cin>>n>>m;
memset(father,-1,sizeof(int)*(n+1));
int a,b,ans=0;
while(m--){
cin>>a>>b;
Union(a,b);
}
for(int i=1;i<=n;i++){
if(father[i]==-1) ans++;
}
cout<<ans<<endl;
return 0;
}