#include <bitset>
#include <fstream>
#include <vector>
std::ifstream in("dfs.in");
std::ofstream out("dfs.out");
std::vector<std::vector<int>> graph;
std::bitset<100001> visited;
void dfs(int node) {
visited.set(node);
for (int next : graph[node]) {
if (visited[next]) {
continue;
}
visited.set(next);
dfs(next);
}
}
int main() {
int n, m;
in >> n >> m;
graph.assign(n + 1, std::vector<int>());
for (int i = 0; i < m; i++) {
int x, y;
in >> x >> y;
graph[x].push_back(y);
graph[y].push_back(x);
}
int cc_count = 0;
for (int node = 1; node <= n; node++) {
if (!visited[node]) {
dfs(node);
cc_count++;
}
}
out << cc_count;
}