import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
      int x1 = scan.nextInt();
      int x2 = scan.nextInt();
      int x3 = scan.nextInt();
      int x4 = scan.nextInt();
      int x5 = scan.nextInt();
      int ans = 0;
      
      if(x1 == 0)
        ans = 1;
      else if(x2 == 0)
        ans = 2;
      else if(x3 == 0)
        ans = 3;
      else if(x4 == 0)
        ans = 4;
      else
        ans = 5;
      
      System.out.println(ans);
   }
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
      int x1 = scan.nextInt();
      int x2 = scan.nextInt();
      int x3 = scan.nextInt();
      int x4 = scan.nextInt();
      int x5 = scan.nextInt();
      int ans = 0;
      
      if(x1 == 0)
        ans = 1;
      else if(x2 == 0)
        ans = 2;
      else if(x3 == 0)
        ans = 3;
      else if(x4 == 0)
        ans = 4;
      else
        ans = 5;
      
      System.out.println(ans);
   }
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
      int x1 = scan.nextInt();
      int x2 = scan.nextInt();
      int x3 = scan.nextInt();
      int x4 = scan.nextInt();
      int x5 = scan.nextInt();
      int ans = 0;
      
      if(x1 == 0)
        ans = 1;
      else if(x2 == 0)
        ans = 2;
      else if(x3 == 0)
        ans = 3;
      else if(x4 == 0)
        ans = 4;
      else
        ans = 5;
      
      System.out.println(ans);
   } main {
		Scanner scan = new Scanner(System.in);
      int x1 = scan.nextInt();
      int x2 = scan.nextInt();
      int x3 = scan.nextInt();
      int x4 = scan.nextInt();
      int x5 = scan.nextInt();
      int ans = 0;
      
      if(x1 == 0)
        ans = 1;
      else if(x2 == 0)
        ans = 2;
      else if(x3 == 0)
        ans = 3;
      else if(x4 == 0)
        ans = 4;
      else
        ans = 5;
      
      System.out.println(ans);
   } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int x1 = scan.nextInt(); x1 scan.nextInt() scan.nextInt scan int x2 = scan.nextInt(); x2 scan.nextInt() scan.nextInt scan int x3 = scan.nextInt(); x3 scan.nextInt() scan.nextInt scan int x4 = scan.nextInt(); x4 scan.nextInt() scan.nextInt scan int x5 = scan.nextInt(); x5 scan.nextInt() scan.nextInt scan int ans = 0; ans 0 if(x1 == 0)
        ans = 1;
      else if(x2 == 0)
        ans = 2;
      else if(x3 == 0)
        ans = 3;
      else if(x4 == 0)
        ans = 4;
      else
        ans = 5; x1 == 0 x1 0 ans = 1 ans 1 if(x2 == 0)
        ans = 2;
      else if(x3 == 0)
        ans = 3;
      else if(x4 == 0)
        ans = 4;
      else
        ans = 5; x2 == 0 x2 0 ans = 2 ans 2 if(x3 == 0)
        ans = 3;
      else if(x4 == 0)
        ans = 4;
      else
        ans = 5; x3 == 0 x3 0 ans = 3 ans 3 if(x4 == 0)
        ans = 4;
      else
        ans = 5; x4 == 0 x4 0 ans = 4 ans 4 ans = 5 ans 5 System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
      int x1 = scan.nextInt();
      int x2 = scan.nextInt();
      int x3 = scan.nextInt();
      int x4 = scan.nextInt();
      int x5 = scan.nextInt();
      int ans = 0;
      
      if(x1 == 0)
        ans = 1;
      else if(x2 == 0)
        ans = 2;
      else if(x3 == 0)
        ans = 3;
      else if(x4 == 0)
        ans = 4;
      else
        ans = 5;
      
      System.out.println(ans);
   }
} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
      int x1 = scan.nextInt();
      int x2 = scan.nextInt();
      int x3 = scan.nextInt();
      int x4 = scan.nextInt();
      int x5 = scan.nextInt();
      int ans = 0;
      
      if(x1 == 0)
        ans = 1;
      else if(x2 == 0)
        ans = 2;
      else if(x3 == 0)
        ans = 3;
      else if(x4 == 0)
        ans = 4;
      else
        ans = 5;
      
      System.out.println(ans);
   }
} Main
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
      int x1 = scan.nextInt();
      int x2 = scan.nextInt();
      int x3 = scan.nextInt();
      int x4 = scan.nextInt();
      int x5 = scan.nextInt();
      int ans = 0;
      
      if(x1 == 0)
        ans = 1;
      else if(x2 == 0)
        ans = 2;
      else if(x3 == 0)
        ans = 3;
      else if(x4 == 0)
        ans = 4;
      else
        ans = 5;
      
      System.out.println(ans);
   }
}