#include <stdio.h>
#include <stack>
#include <vector>
#define NMAX 100001
using namespace std;
vector<int> adjList[NMAX];
bool visited[NMAX];
int n, m, s;
void DFS(int root) {
visited[root] = true;
for (int i = 0; i < adjList[root].size(); ++i) {
if (!visited[adjList[root][i]]) {
DFS(adjList[root][i]);
}
}
}
int main() {
FILE *in, *out;
in = fopen("dfs.in", "r");
out = fopen("dfs.out", "w");
int a, b;
fscanf(in, "%d%d", &n, &m);
for (int i = 0; i < m; ++i) {
fscanf(in, "%d%d", &a, &b);
adjList[a].push_back(b);
adjList[b].push_back(a);
}
int count = 0;
for (int i = 1; i <= n; ++i) {
if (!visited[i]) {
++ count;
DFS(i);
}
}
fprintf(out, "%d\n", count);
}