#include <fstream>
#include <vector>
using namespace std;
ifstream fin("dfs.in");
ofstream fout("dfs.out");
int n, m, x, y, nr;
vector <int> l[100005];
bool viz[100005];
void DFS(int nod)
{
int i;
viz[nod] = 1;
for ( i = 0; i < l[nod].size(); i++)
{
if (viz[l[nod][i]] == 0)
DFS(l[nod][i]);
}
}
void Citire()
{
fin >> n >> m;
for (int i = 1; i <= m; i++)
{
fin >> x >> y;
l[x].push_back(y);
l[y].push_back(x);
}
}
void Rezolvare()
{
int i;
for (i = 1; i <= n; i++)
{
if (viz[i] == 0)
{
nr++;
DFS(i);
}
}
fout << nr;
}
int main()
{
Citire();
Rezolvare();
return 0;
}