program pie;
const
max=1000000;
var
a:array[1..max]of longint;
b:array[1..max]of longint;
mx,total,x,y,i,n:longint;
bo:boolean;
f1,f2:text;
begin
assign(f1,'pie.in'); assign(f2,'pie.out');
reset(f1); rewrite(f2);
read(f1,n);
for i:=1 to n do
begin
read(f1,x,y);
if mx<x then mx:=x;
if mx<y then mx:=y;
inc(a[x]);
inc(b[y]);
end;
bo:=false;
for i:=1 to mx do
if (b[i]>0)or(a[i]>0) then
begin
if a[i]>b[i] then total:=total+a[i] else total:=total+b[i];
if b[i]<>a[i] then bo:=true;
end;
if bo=false then inc(total);
write(f2,total);
close(f1); close(f2);
end.