program board;
type
fxz1=array[1..200000]of longint;
fxz2=record x,y:longint;end;
fxz3=array[1..600000] of fxz2;
var
f1,f2:text;
ans,i,n,m:longint;
xx,yy:fxz1;
p:fxz3;
begin
assign(f1,'board.in');
assign(f2,'board.out');
reset(f1);rewrite(f2);
readln(f1,n,m);
for i:=1 to n do
begin
xx[i]:=0;
yy[i]:=0;
end;
for i:=1 to m do
begin
readln(f1,p[i].x,p[i].y);
inc(xx[p[i].x]);
inc(yy[p[i].y]);
end;
ans:=0;
for i:=1 to m do
if (xx[p[i].x]>0)or(xx[p[i].y]>0) then inc(ans);
writeln(f2,ans);
close(f1);close(f2);
end.