import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int X1  = sc.nextInt();
    int X2 = sc.nextInt();
    int X3 = sc.nextInt();
    int X4 = sc.nextInt();
    int X5 = sc.nextInt();
 
    if(X1==0){
	System.out.println("1");
    }else if(X2==0){
	System.out.println("2");     
    }else if(X3==0){
	System.out.println("3");
    }else if(X4==0){
	System.out.println("4");
    }else{        
	System.out.println("5");
	}
}
} import java.util.*; util.* java public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int X1  = sc.nextInt();
    int X2 = sc.nextInt();
    int X3 = sc.nextInt();
    int X4 = sc.nextInt();
    int X5 = sc.nextInt();
 
    if(X1==0){
	System.out.println("1");
    }else if(X2==0){
	System.out.println("2");     
    }else if(X3==0){
	System.out.println("3");
    }else if(X4==0){
	System.out.println("4");
    }else{        
	System.out.println("5");
	}
}
} Main public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int X1  = sc.nextInt();
    int X2 = sc.nextInt();
    int X3 = sc.nextInt();
    int X4 = sc.nextInt();
    int X5 = sc.nextInt();
 
    if(X1==0){
	System.out.println("1");
    }else if(X2==0){
	System.out.println("2");     
    }else if(X3==0){
	System.out.println("3");
    }else if(X4==0){
	System.out.println("4");
    }else{        
	System.out.println("5");
	}
} main {
    
    Scanner sc = new Scanner(System.in);
    int X1  = sc.nextInt();
    int X2 = sc.nextInt();
    int X3 = sc.nextInt();
    int X4 = sc.nextInt();
    int X5 = sc.nextInt();
 
    if(X1==0){
	System.out.println("1");
    }else if(X2==0){
	System.out.println("2");     
    }else if(X3==0){
	System.out.println("3");
    }else if(X4==0){
	System.out.println("4");
    }else{        
	System.out.println("5");
	}
} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int X1  = sc.nextInt(); X1 sc.nextInt() sc.nextInt sc int X2 = sc.nextInt(); X2 sc.nextInt() sc.nextInt sc int X3 = sc.nextInt(); X3 sc.nextInt() sc.nextInt sc int X4 = sc.nextInt(); X4 sc.nextInt() sc.nextInt sc int X5 = sc.nextInt(); X5 sc.nextInt() sc.nextInt sc if(X1==0){
	System.out.println("1");
    }else if(X2==0){
	System.out.println("2");     
    }else if(X3==0){
	System.out.println("3");
    }else if(X4==0){
	System.out.println("4");
    }else{        
	System.out.println("5");
	} X1==0 X1 0 {
	System.out.println("1");
    } System.out.println("1") System.out.println System.out System System.out "1" if(X2==0){
	System.out.println("2");     
    }else if(X3==0){
	System.out.println("3");
    }else if(X4==0){
	System.out.println("4");
    }else{        
	System.out.println("5");
	} X2==0 X2 0 {
	System.out.println("2");     
    } System.out.println("2") System.out.println System.out System System.out "2" if(X3==0){
	System.out.println("3");
    }else if(X4==0){
	System.out.println("4");
    }else{        
	System.out.println("5");
	} X3==0 X3 0 {
	System.out.println("3");
    } System.out.println("3") System.out.println System.out System System.out "3" if(X4==0){
	System.out.println("4");
    }else{        
	System.out.println("5");
	} X4==0 X4 0 {
	System.out.println("4");
    } System.out.println("4") System.out.println System.out System System.out "4" {        
	System.out.println("5");
	} System.out.println("5") System.out.println System.out System System.out "5" String[] args args public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int X1  = sc.nextInt();
    int X2 = sc.nextInt();
    int X3 = sc.nextInt();
    int X4 = sc.nextInt();
    int X5 = sc.nextInt();
 
    if(X1==0){
	System.out.println("1");
    }else if(X2==0){
	System.out.println("2");     
    }else if(X3==0){
	System.out.println("3");
    }else if(X4==0){
	System.out.println("4");
    }else{        
	System.out.println("5");
	}
}
} public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int X1  = sc.nextInt();
    int X2 = sc.nextInt();
    int X3 = sc.nextInt();
    int X4 = sc.nextInt();
    int X5 = sc.nextInt();
 
    if(X1==0){
	System.out.println("1");
    }else if(X2==0){
	System.out.println("2");     
    }else if(X3==0){
	System.out.println("3");
    }else if(X4==0){
	System.out.println("4");
    }else{        
	System.out.println("5");
	}
}
} Main
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int X1  = sc.nextInt();
    int X2 = sc.nextInt();
    int X3 = sc.nextInt();
    int X4 = sc.nextInt();
    int X5 = sc.nextInt();
 
    if(X1==0){
	System.out.println("1");
    }else if(X2==0){
	System.out.println("2");     
    }else if(X3==0){
	System.out.println("3");
    }else if(X4==0){
	System.out.println("4");
    }else{        
	System.out.println("5");
	}
}
}