#include <iostream> #include <vector> #include <cassert> #include <queue> using namespace std; const int vmax=100010; vector<int> graph[vmax]; bool visited[vmax]; void bfs(int v){ visited[v]=true; queue<int> q; q.push(v); while(!q.empty()){ int cur=q.front();q.pop(); for(auto &nxt:graph[cur]){ if(visited[nxt]) continue; visited[nxt]=true; q.push(nxt); } } return ; } int main(void){ int N,M; cin >> N >> M; assert(1<=N&&N<=100000); assert(0<=M&&M<=200000); for(int loop=0;loop<M;++loop){ int a,b; cin >> a >> b; assert(1<=a&&a<=N); assert(1<=b&&b<=N); graph[a-1].push_back(b-1); graph[b-1].push_back(a-1); } int ans=0; for(int v=0;v<N;++v){ if(visited[v]) continue; ans++,bfs(v); } cout << ans << endl; return 0; }