#include<stdio.h>
int main(){
int hour[2][7], max=0, max_index=0, temp;
for (int i=0;i<7;i++){
scanf("%d %d", &hour[0][i], &hour[1][i]);
}
for (int i=0;i<7;i++){
temp = hour[0][i]+hour[1][i];
if (max<temp){
max =temp;
max_index = i;
}
}
if (max>8){
printf("%d", max_index+1);
}
else{
printf("0");
}
return 0;
}