#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
using namespace std;
#ifdef HOME
const string inputFile = "input.txt";
const string outputFile = "output.txt";
#else
const string problemName = "dfs";
const string inputFile = problemName + ".in";
const string outputFile = problemName + ".out";
#endif
const int NMAX = 100000 + 5;
int N, M, sol;
vector<int> V[NMAX];
bitset<NMAX> viz;
void dfs(int x) {
viz[x] = 1;
for(auto y : V[x])
if(!viz[y])
dfs(y);
}
int main() {
int i, x, y;
freopen(inputFile.c_str(), "r", stdin);
freopen(outputFile.c_str(), "w", stdout);
scanf("%d%d", &N, &M);
while(M--) {
scanf("%d%d", &x, &y);
V[x].push_back(y);
V[y].push_back(x);
}
for(i = 1; i <= N; i++)
if(!viz[i]) {
dfs(i);
sol++;
}
printf("%d\n", sol);
return 0;
}