program Project1; {$APPTYPE CONSOLE} var f:text; n,i, k, c:int64; da:array[1..20000,1..2] of int64; sd:array[1..20000] of boolean; begin assign(f, 'task.in'); reset(f); readln(f, n); FillChar(sd, n, 1); i:=0; repeat inc(i); readln(f, da[i,1], da[i,2]); until(i=n); c:=0; i:=0; repeat inc(i); k:=i; repeat inc(k); if (da[i, 1]>=da[k,1]) and (da[i,2]>=da[k,2]) and (sd[k]) then begin inc(c); sd[k]:=False; end else if (da[i, 1]<=da[k,1]) and (da[i,2]<=da[k,2]) and (sd[i]) then begin inc(c); sd[i]:=False; end else if (da[i, 1]<=da[k,2]) and (da[i,2]<=da[k,1]) and (sd[i]) then begin inc(c); sd[i]:=False; end else if (da[i, 1]>=da[k,2]) and (da[i,2]>=da[k,1]) and (sd[k]) then begin sd[k]:=False; inc(c); end; until(k=n); until(i=n-1); close(f); assign(f, 'task.out'); rewrite(f); writeln(f, c); close(f); end.