#include<iostream>
using namespace std;
int main()
{
int cnt = 0;
for(int i = 0; i <= 7; i++)
{
int a, b;
cin >> a >> b;
if(a + b > 8){
cnt = i + 1;
break;
}
}
cout << cnt << endl;
return 0;
}