#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
const int MAXN = 100000;
int n,m,nr;
vector<int> G[MAXN + 1];
bool vis[MAXN + 1];
void dfs(int node) {
vis[node] = true;
for (int vecin : G[node]) {
if (!vis[vecin])
dfs(vecin);
}
}
int main()
{
ifstream fin("dfs.in");
ofstream fout("dfs.out");
fin>>n>>m;
for (int i = 0; i < m; i++) {
int x, y;
fin >> x >> y;
G[x].push_back(y);
G[y].push_back(x);
}
for (int i = 1; i <= n; i++) {
if (!vis[i]) {
nr++;
dfs(i);
}
}
fout<<nr;
return 0;
}