program hotel;
type data=record
se:longint;
money:longint;
end;
var
n,se,money:longint;
a:array[1..2000000] of data;
e,i,j,p:longint;
procedure sum;
begin
e:=0;
for i:=1 to n do
for j:=1 to n do
if (i<>j) and (a[i].se=a[j].se)
then inc(e);
end;
function work(o:longint):longint;
var
r,l:longint;
begin
r:=0;
l:=0;
for i:=1 to n do
begin
r:=0;
p:=0;
for j:=1 to n do
begin
if (i<>j) and (a[i].se=a[j].se)
then if i>j then begin
p:=j;
repeat
if a[p].money<=money then r:=1;
inc(p);
until p=i+1;
end
else if i<j then begin
p:=i;
repeat
if a[p].money<=money then r:=1;
inc(p);
until p=j+1;
end;
if r=1 then inc(l);
end;
end;
work:=l;
end;
begin
readln(n,se,money);
for i:=1 to n do
readln(a[i].se,a[i].money);
sum;
writeln(work(e) div 2);
end.