var n,n1,i,j,x,y,sum:longint;
a:array[0..1000] of longint;
m:array[1..200,1..200] of longint;
begin
assign(input,'flyer.in');reset(input);
assign(output,'flyer.out');rewrite(output);
readln(n1,n);
while not eoln do
begin
readln(i,j);
m[i,j]:=1;
inc(a[j]);
end;
a[0]:=1000;
sum:=0;
for i:=1 to n do
begin
j:=n+1;
x:=0;
while j<=n1 do
begin
if m[i,j]=1 then
if (a[j]<a[x]) and (a[j]<>0) then x:=j;
if a[x]=1 then j:=n1;
inc(j);
end;
if x<>0 then
begin
inc(sum);
a[x]:=0;
end;
end;
writeln(sum);
close(input);close(output);
end.