#include <iostream>
using namespace std;
int main() {
int day_unhappy = 0;
int max_unhappy_hours = 0;
for (int i = 1; i <= 7; i++) {
int school_hours, extra_hours;
cin >> school_hours >> extra_hours;
int total_hours = school_hours + extra_hours;
if (total_hours > 8) {
int unhappy_hours = total_hours - 8;
if (unhappy_hours > max_unhappy_hours) {
max_unhappy_hours = unhappy_hours;
day_unhappy = i;
}
}
}
cout << day_unhappy << endl;
return 0;
}