var n,m,i,j,k,s1,s2,ans,x,y:longint;
a,u:array[1..100,1..100]of boolean;
begin
readln(n,m);
fillchar(a,sizeof(a),false);
fillchar(u,sizeof(u),false);
for i:=1 to m do begin
readln(x,y);
a[x,y]:=true;
u[y,x]:=true;
end;
for k:=1 to n do
for i:=1 to n do
for j:=1 to n do
if (i<>j)and(j<>k)and(i<>k) then begin
a[i,j]:=a[i,j]or((a[i,k])and(a[k,j]));
u[i,j]:=u[i,j]or((u[i,k])and(u[k,j]));
end;
for i:=1 to n do begin
s1:=0; s2:=0;
for j:=1 to n do begin
if (i<>j)and(a[i,j]) then inc(s1);
if (i<>j)and(u[i,j]) then inc(s2);
end;
if (s1>(n-1)div 2)or(s2>(n-1)div 2)then inc(ans);
end;
writeln(ans);
end.