var g:array[1..200,1..200] of boolean;
l:array[1..200] of longint;
ok:array[1..200] of boolean;
y,z,n,t,x,m,i,j:longint;
function find(v:longint):boolean;
var i:longint;
begin
if v=0 then exit(true);
for i:=1 to n do
if ok[i] and g[v,i] then
begin
t:=l[i]; l[i]:=v; ok[i]:=false;
if (t=0) or (find(t)) then exit(true);
l[i]:=t;
end;
exit(false);
end;
begin
read(n,m); for i:=1 to m do begin read(y,z); g[y,z]:=true; end; m:=0;
for i:=1 to n do
begin
fillchar(ok,sizeof(ok),true);
if find(i) then inc(m);
end;
writeln(m);
end.
l:array[1..200] of longint;
ok:array[1..200] of boolean;
y,z,n,t,x,m,i,j:longint;
function find(v:longint):boolean;
var i:longint;
begin
if v=0 then exit(true);
for i:=1 to n do
if ok[i] and g[v,i] then
begin
t:=l[i]; l[i]:=v; ok[i]:=false;
if (t=0) or (find(t)) then exit(true);
l[i]:=t;
end;
exit(false);
end;
begin
read(n,m); for i:=1 to m do begin read(y,z); g[y,z]:=true; end; m:=0;
for i:=1 to n do
begin
fillchar(ok,sizeof(ok),true);
if find(i) then inc(m);
end;
writeln(m);
end.