// DFS.cpp : Defines the entry point for the console application.
//
#include <stdio.h>
int n, m;
int math[10][10], nod[10], numarator = 0;
void citire()
{
freopen("dfs.in", "r", stdin);
freopen("dfs.out", "w", stdout);
scanf("%d %d", &n, &m);
int i, x, y;
for (i = 1; i <= m; i++)
{
scanf("%d %d", &x, &y);
math[x][y] = math[y][x] = 1;
}
}
void dfs_lb(int nod_start)
{
nod[nod_start] = 1;
for (int i = 1; i <= n; i++)
if (nod[i] == 0 && math[nod_start][i] == 1)
dfs_lb(i);
}
void dfs()
{
for (int i = 1; i <= n; i++)
if (nod[i] == 0)
{
numarator++;
dfs_lb(i);
}
}
int main()
{
citire();
dfs();
printf("%d\n", numarator);
return 0;
}