#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
//谢谢博友好文章
class hi
{
public:
int x;
int y;
int z;
};
bool s1(class hi a,class hi b)
{
if(a.x==b.x)
{
return a.y<b.y;
}
return(a.x<b.x);
}
bool s2(class hi a,class hi b)
{
return(a.y<b.y);
}
int main()
{
int NUM1,NUM2;
//cin>>NUM1>>NUM2;
scanf("%d%d",&NUM1,&NUM2);
//cout<<NUM1<<" "<<NUM2<<endl;
vector<class hi> da;
for(int i=0;i<NUM1;i++)
{
int tx;
int ty;
//cin>>tx>>ty;
char c;
scanf("%d%d",&tx,&ty);
//cout<<tx<<" "<<ty<<endl;
class hi t;
t.x=tx;
t.y=ty;
t.z=i+1;
da.push_back(t);
}
sort(da.begin(),da.end(),s1);
sort(da.end()-NUM2,da.end(),s2);
cout<<da[NUM1-1].z;
return 0;
}