#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream fin("dfs.in");
ofstream fout("dfs.out");
const int NMax = 1e5;
vector <int> g[NMax + 5];
int n, m, ans;
bool use[NMax + 5];
void Read(){
fin >> n >> m;
while (m--){
int x, y;
fin >> x >> y;
g[x].push_back(y);
g[y].push_back(x);
}
}
void DFS(int node){
use[node] = 1;
for (auto ngh : g[node])
if (!use[ngh])
DFS(ngh);
}
void Solve(){
for (int i = 1; i <= n; i++)
if (!use[i]){
ans++;
DFS(i);
}
}
void Print(){
fout << ans << '\n';
}
int main(){
Read();
Solve();
Print();
return 0;
}