program p1;
type lista=^celula;
celula = record
infor:longint;
urm:lista;
end;
var a:array[0..1000010] of lista;
viz:array[0..10000] of 0..1;
b1,b2:array[0..1 shl 17 ] of char;
f,g:text;
i,n,j,u,m,i_s,x,y,sol:longint;
v:lista;
procedure dfs(nod:longint);
var r:lista;
begin
viz[nod]:=1;
r:=a[nod];
while r<>nil do begin
if (viz[r^.infor]=0) then dfs(r^.infor);
r:=r^.urm;
end;
end;
begin
assign(f,'dfs.in');settextbuf(f,b1);reset(F);
assign(g,'dfs.out');settextbuf(g,b2);rewrite(G);
readln(f,n,m);
for i:=1 to m do
begin
readln(f,x,y);
new(V);
v^.infor:=y;
v^.urm:=a[x];
a[x]:=v;
new(V);
v^.infor:=x;
v^.urm:=a[y];
a[y]:=v;
end;
for i:=1 to n do viz[i]:=0;
for i:=1 to n do
if viz[i]=0 then begin
inc(sol);
dfs(i);
end;
writeln(g,sol);
close(F);
close(G);
end.