#include <bits/stdc++.h>
using namespace std;
int main() {
int a[101], b[101], sum = 0, c = 0;
for (int i = 1; i <= 7; i++) {
cin >> a[i] >> b[i];
if (a[i] + b[i] > 8 && c == 0) {
sum = i;
c++;
}
}
cout << sum;
return 0;
}