#include<iostream>
using namespace std;
int main() {
int v[10000000];int ti[10000000];
int high[10000000];
bool block[10000000];
int n, t;
cin >> n >> t;
for (int i = 0; i < n; i++) {
cin >> v[i];
cin >> ti[i];
block[i] = 0;
high[i] = 0;
} int m;
for (int j = 0; j < t; j++) {
for (m = 0; m < n; m++) {
if (!block[m] && ti[m] <= j)
block[m] = 1;
if (block[m])
high[m] += v[m];
}
}
int highest = high[0], highs = 0;
for (int o = 0; o < n; o++)
if (high[o] > highest) {
highest = high[o];
highs = o;
}
cout << highs + 1;
return 0;
}