#include<bits/stdc++.h>
using namespace std;
const int N=50005;
int n,m,fa[N];
int find(int x){
return fa[x]==x?x:fa[x]=find(fa[x]);
}
int main(){
freopen("religion.in","r",stdin);
freopen("religion.out","w",stdout);
scanf("%d%d",&n,&m);
for(int i = 1;i<=n;i++) fa[i]=i;
while(m--){
int x,y; scanf("%d%d",&x,&y);
int fx=find(x),fy=find(y);
if(fx!=fy) fa[fx]=fy;
}
int ans=0;
for(int i = 1;i<=n;i++)
if(fa[i]==i) ans++;
printf("%d",ans);
return 0;
}