#include <fstream>
#include <vector>
#include <bitset>
using namespace std;
ifstream f("dfs.in");
ofstream g("dfs.out");
int no_cc;
constexpr int NMAX = 100005;
vector<vector<int>>graph;
bitset<NMAX>used;
void dfs(int node)
{
used[node]=1;
for(int next:graph[node])
if(!used[next])
dfs(next);
}
int main() {
int n,m;
f >> n >> m;
graph.assign(n + 1,vector<int>());
for(int i=1; i<=m; i++)
{
int x, y;
f>>x>>y;
graph[x].push_back(y);
graph[y].push_back(x);
}
for(int i=1; i<=n; i++)
if(!used[i])
{
no_cc++;
dfs(i);
}
g<<no_cc;
return 0;
}