java
import java.util.*;
public class UnhappyDeJingJing {
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int []a=new int[7];
int []b=new int[7];
int []c=new int[7];
int count=-1;
for(int i=0;i<7;i++){
a[i]=sc.nextInt();
b[i]=sc.nextInt();
}
for(int i=0;i<7;i++){
c[i]=a[i]+b[i];
if(c[i]>8 && c[i]>c[i+1])
count=i;
}
if(count<0)
System.out.println('0');
else
{
for(int i=0;i<7;i++){
for(int j=0;j<7-i-1;j++){
int temp;
if(c[j]>c[j+1])
{
temp=c[j];
c[j]=c[j+1];
c[j+1]=temp;
}
}
}
int count1=0;
for(int i=count-1;i>=0;i--){
if(c[i]==c[count]){
count1++;
}
}
if(count1>0){
System.out.println((count+1-count1));
}
else{
System.out.println((count+1));
}
}
}
}