var n,k,i,j,max,ans:longint;
a,b,num:array[1..50000]of longint;
procedure sort(x,y:longint);
var i,j,k,l:longint;
begin
i:=x;
j:=y;
k:=a[(i+j)>>1];
repeat
while a[i]>k do inc(i);
while a[j]<k do dec(j);
if i<=j then
begin
l:=a[i];
a[i]:=a[j];
a[j]:=l;
l:=b[i];
b[i]:=b[j];
b[j]:=l;
l:=num[i];
num[i]:=num[j];
num[j]:=l;
inc(i);
dec(j);
end;
until i>j;
if x<j then sort(x,j);
if i<y then sort(i,y);
end;
begin
assign(input,'elect.in');
assign(output,'elect.out');
reset(input);
rewrite(output);
readln(n,k);
for i:=1 to n do
begin
readln(a[i],b[i]);
num[i]:=i;
end;
sort(1,n);
for i:=1 to k do
if max<b[i] then
begin
max:=b[i];
ans:=num[i];
end;
writeln(ans);
close(input);
close(output);
end.