#include <bits/stdc++.h>
using namespace std;
int n,m,ans;
bitset<100001> vis;
vector<int> a[100001];
int rec(int u,int par){
vis[u]=1;
int ret=1;
for(int v:a[u])
if(v==par)
continue;
else if(vis[v])
ret&=0;
else
if(!rec(v,u))
ret&=0;
return ret;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(NULL);
cin>>n>>m;
for(int i=0;i<m;i++){
int u,v;
cin>>u>>v;
a[u].push_back(v);
a[v].push_back(u);
}
for(int i=1;i<=n;i++){
if(!vis[i])
ans+=rec(i,i);
}
cout<<ans<<'\n';
}
Comments
Post a Comment