#include<bits/stdc++.h>
using namespace std;
long long n,m,x,y,fa[50005],as;
long long f(long long x){
if(fa[x]!=x){
fa[x]=f(fa[x]);
}
return fa[x];
}
int main(){
freopen("religion.in","r",stdin);
freopen("religion.out","w",stdout);
scanf("%lld%lld",&n,&m);
for(long long i=1;i<=n;i++){
fa[i]=i;
}
for(long long i=1;i<=m;i++){
scanf("%lld%lld",&x,&y);
fa[f(x)]=f(y);
}
for(long long i=1;i<=n;i++){
if(fa[i]==i){
as++;
}
}
printf("%lld",as);
return 0;
}