#include<iostream>
#include<limits>
using namespace std;
class jinjin {
public:
int a[7], b[7];
void setValues() {
for(int i = 0; i < 7; i++) {
cin >> a[i] >> b[i];
}
}
int findMostUnhappyDay() {
int mostUnhappyDay = 0;
int longestHours = 0;
for(int n = 0; n < 7; n++) {
if(a[n] + b[n] > 8 && a[n] + b[n] > longestHours) {
longestHours = a[n] + b[n];
mostUnhappyDay = n + 1;
}
}
return mostUnhappyDay;
}
void checkValues() {
int day = findMostUnhappyDay();
if(day != 0) {
cout << day << endl;
}
}
};
int main() {
jinjin j;
j.setValues();
j.checkValues();
return 0;
}