import java.io.*;import java.util.*;

public class Main{
    static class FastReader{
        BufferedReader br; 
        StringTokenizer st; 
        public FastReader(){br = new BufferedReader(new InputStreamReader(System.in));} 
        String next(){while (st == null || !st.hasMoreElements()){try{st = new StringTokenizer(br.readLine());}catch (IOException  e){e.printStackTrace();}}return st.nextToken();} 
        int nextInt(){return Integer.parseInt(next());} 
        long nextLong(){return Long.parseLong(next());} 
        double nextDouble(){return Double.parseDouble(next());} 
        int[] readArray(int n){int[] a=new int[n];for (int i=0; i<n; i++) a[i]=nextInt();return a;}
        long[] readLongArray(int n){long[] a=new long[n];for (int i=0; i<n; i++) a[i]=nextLong();return a;}
        String nextLine(){String str = "";try{str = br.readLine();}catch (IOException e){e.printStackTrace();}return str;} 
    }
    static int getgcd(int n1,int n2){
        while(n1 != n2){
            if(n1 > n2) n1 -= n2;
            else n2 -= n1;
        }
        return n1;
    }
    static boolean isSorted(int[] arr, int n){
        for(int i=1;i<n;i++){
            if(arr[i]<arr[i-1]) return false;
        }
        return true;
    }
    static boolean isPrime(long n){
        if(n==2) return true;
        else if(n%2==0) return false;
        for(int i=3;i<=n/2;i+=2){
            if(n%i==0) return false;
        }
        return true;
    }
    static void printArray(int[] arr){
        for(int x:arr){
            System.out.print(x+" ");
        }
        System.out.println();
    }
    public static void main(String[] args) throws NumberFormatException, IOException {
        FastReader s=new FastReader();
        //int t = s.nextInt();
        int[] a = s.readArray(5);
        boolean test;
        //while(t>0){
            //test=true;
            if(a[0]==0) System.out.println("1");
            else if(a[1]==0) System.out.println("2");
            else if(a[2]==0) System.out.println("3");
            else if(a[3]==0) System.out.println("4");
            else if(a[4]==0) System.out.println("5");
            //t--;
       // }
    }
} import java.io.*; io.* java import java.util.*; util.* java public class Main{
    static class FastReader{
        BufferedReader br; 
        StringTokenizer st; 
        public FastReader(){br = new BufferedReader(new InputStreamReader(System.in));} 
        String next(){while (st == null || !st.hasMoreElements()){try{st = new StringTokenizer(br.readLine());}catch (IOException  e){e.printStackTrace();}}return st.nextToken();} 
        int nextInt(){return Integer.parseInt(next());} 
        long nextLong(){return Long.parseLong(next());} 
        double nextDouble(){return Double.parseDouble(next());} 
        int[] readArray(int n){int[] a=new int[n];for (int i=0; i<n; i++) a[i]=nextInt();return a;}
        long[] readLongArray(int n){long[] a=new long[n];for (int i=0; i<n; i++) a[i]=nextLong();return a;}
        String nextLine(){String str = "";try{str = br.readLine();}catch (IOException e){e.printStackTrace();}return str;} 
    }
    static int getgcd(int n1,int n2){
        while(n1 != n2){
            if(n1 > n2) n1 -= n2;
            else n2 -= n1;
        }
        return n1;
    }
    static boolean isSorted(int[] arr, int n){
        for(int i=1;i<n;i++){
            if(arr[i]<arr[i-1]) return false;
        }
        return true;
    }
    static boolean isPrime(long n){
        if(n==2) return true;
        else if(n%2==0) return false;
        for(int i=3;i<=n/2;i+=2){
            if(n%i==0) return false;
        }
        return true;
    }
    static void printArray(int[] arr){
        for(int x:arr){
            System.out.print(x+" ");
        }
        System.out.println();
    }
    public static void main(String[] args) throws NumberFormatException, IOException {
        FastReader s=new FastReader();
        //int t = s.nextInt();
        int[] a = s.readArray(5);
        boolean test;
        //while(t>0){
            //test=true;
            if(a[0]==0) System.out.println("1");
            else if(a[1]==0) System.out.println("2");
            else if(a[2]==0) System.out.println("3");
            else if(a[3]==0) System.out.println("4");
            else if(a[4]==0) System.out.println("5");
            //t--;
       // }
    }
} Main static int getgcd(int n1,int n2){
        while(n1 != n2){
            if(n1 > n2) n1 -= n2;
            else n2 -= n1;
        }
        return n1;
    } getgcd {
        while(n1 != n2){
            if(n1 > n2) n1 -= n2;
            else n2 -= n1;
        }
        return n1;
    } while(n1 != n2){
            if(n1 > n2) n1 -= n2;
            else n2 -= n1;
        } n1 != n2 n1 n2 {
            if(n1 > n2) n1 -= n2;
            else n2 -= n1;
        } if(n1 > n2) n1 -= n2;
            else n2 -= n1; n1 > n2 n1 n2 n1 -= n2 n1 n2 n2 -= n1 n2 n1 return n1; n1 int n1 n1 int n2 n2 static boolean isSorted(int[] arr, int n){
        for(int i=1;i<n;i++){
            if(arr[i]<arr[i-1]) return false;
        }
        return true;
    } isSorted {
        for(int i=1;i<n;i++){
            if(arr[i]<arr[i-1]) return false;
        }
        return true;
    } for(int i=1;i<n;i++){
            if(arr[i]<arr[i-1]) return false;
        } int i=1; int i=1; i 1 i<n i n i++ i++ i {
            if(arr[i]<arr[i-1]) return false;
        } {
            if(arr[i]<arr[i-1]) return false;
        } if(arr[i]<arr[i-1]) return false; arr[i]<arr[i-1] arr[i] arr i arr[i-1] arr i-1 i 1 return false; false return true; true int[] arr arr int n n static boolean isPrime(long n){
        if(n==2) return true;
        else if(n%2==0) return false;
        for(int i=3;i<=n/2;i+=2){
            if(n%i==0) return false;
        }
        return true;
    } isPrime {
        if(n==2) return true;
        else if(n%2==0) return false;
        for(int i=3;i<=n/2;i+=2){
            if(n%i==0) return false;
        }
        return true;
    } if(n==2) return true;
        else if(n%2==0) return false; n==2 n 2 return true; true if(n%2==0) return false; n%2==0 n%2 n 2 0 return false; false for(int i=3;i<=n/2;i+=2){
            if(n%i==0) return false;
        } int i=3; int i=3; i 3 i<=n/2 i n/2 n 2 i+=2 i+=2 i 2 {
            if(n%i==0) return false;
        } {
            if(n%i==0) return false;
        } if(n%i==0) return false; n%i==0 n%i n i 0 return false; false return true; true long n n static void printArray(int[] arr){
        for(int x:arr){
            System.out.print(x+" ");
        }
        System.out.println();
    } printArray {
        for(int x:arr){
            System.out.print(x+" ");
        }
        System.out.println();
    } for(int x:arr){
            System.out.print(x+" ");
        } int x arr {
            System.out.print(x+" ");
        } {
            System.out.print(x+" ");
        } System.out.print(x+" ") System.out.print System.out System System.out x+" " x " " System.out.println() System.out.println System.out System System.out int[] arr arr public static void main(String[] args) throws NumberFormatException, IOException {
        FastReader s=new FastReader();
        //int t = s.nextInt();
        int[] a = s.readArray(5);
        boolean test;
        //while(t>0){
            //test=true;
            if(a[0]==0) System.out.println("1");
            else if(a[1]==0) System.out.println("2");
            else if(a[2]==0) System.out.println("3");
            else if(a[3]==0) System.out.println("4");
            else if(a[4]==0) System.out.println("5");
            //t--;
       // }
    } main {
        FastReader s=new FastReader();
        //int t = s.nextInt();
        int[] a = s.readArray(5);
        boolean test;
        //while(t>0){
            //test=true;
            if(a[0]==0) System.out.println("1");
            else if(a[1]==0) System.out.println("2");
            else if(a[2]==0) System.out.println("3");
            else if(a[3]==0) System.out.println("4");
            else if(a[4]==0) System.out.println("5");
            //t--;
       // }
    } FastReader s=new FastReader(); s new FastReader() int[] a = s.readArray(5); a s.readArray(5) s.readArray s 5 boolean test; test if(a[0]==0) System.out.println("1");
            else if(a[1]==0) System.out.println("2");
            else if(a[2]==0) System.out.println("3");
            else if(a[3]==0) System.out.println("4");
            else if(a[4]==0) System.out.println("5"); a[0]==0 a[0] a 0 0 System.out.println("1") System.out.println System.out System System.out "1" if(a[1]==0) System.out.println("2");
            else if(a[2]==0) System.out.println("3");
            else if(a[3]==0) System.out.println("4");
            else if(a[4]==0) System.out.println("5"); a[1]==0 a[1] a 1 0 System.out.println("2") System.out.println System.out System System.out "2" if(a[2]==0) System.out.println("3");
            else if(a[3]==0) System.out.println("4");
            else if(a[4]==0) System.out.println("5"); a[2]==0 a[2] a 2 0 System.out.println("3") System.out.println System.out System System.out "3" if(a[3]==0) System.out.println("4");
            else if(a[4]==0) System.out.println("5"); a[3]==0 a[3] a 3 0 System.out.println("4") System.out.println System.out System System.out "4" if(a[4]==0) System.out.println("5"); a[4]==0 a[4] a 4 0 System.out.println("5") System.out.println System.out System System.out "5" String[] args args static class FastReader{
        BufferedReader br; 
        StringTokenizer st; 
        public FastReader(){br = new BufferedReader(new InputStreamReader(System.in));} 
        String next(){while (st == null || !st.hasMoreElements()){try{st = new StringTokenizer(br.readLine());}catch (IOException  e){e.printStackTrace();}}return st.nextToken();} 
        int nextInt(){return Integer.parseInt(next());} 
        long nextLong(){return Long.parseLong(next());} 
        double nextDouble(){return Double.parseDouble(next());} 
        int[] readArray(int n){int[] a=new int[n];for (int i=0; i<n; i++) a[i]=nextInt();return a;}
        long[] readLongArray(int n){long[] a=new long[n];for (int i=0; i<n; i++) a[i]=nextLong();return a;}
        String nextLine(){String str = "";try{str = br.readLine();}catch (IOException e){e.printStackTrace();}return str;} 
    } FastReader BufferedReader br; br StringTokenizer st; st public FastReader(){br = new BufferedReader(new InputStreamReader(System.in));} FastReader {br = new BufferedReader(new InputStreamReader(System.in));} br = new BufferedReader(new InputStreamReader(System.in)) br new BufferedReader(new InputStreamReader(System.in)) String next(){while (st == null || !st.hasMoreElements()){try{st = new StringTokenizer(br.readLine());}catch (IOException  e){e.printStackTrace();}}return st.nextToken();} next {while (st == null || !st.hasMoreElements()){try{st = new StringTokenizer(br.readLine());}catch (IOException  e){e.printStackTrace();}}return st.nextToken();} while (st == null || !st.hasMoreElements()){try{st = new StringTokenizer(br.readLine());}catch (IOException  e){e.printStackTrace();}} st == null || !st.hasMoreElements() st == null st null !st.hasMoreElements() st.hasMoreElements() st.hasMoreElements st {try{st = new StringTokenizer(br.readLine());}catch (IOException  e){e.printStackTrace();}} try{st = new StringTokenizer(br.readLine());}catch (IOException  e){e.printStackTrace();} catch (IOException  e){e.printStackTrace();} IOException  e {e.printStackTrace();} e.printStackTrace() e.printStackTrace e {st = new StringTokenizer(br.readLine());} st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st int nextInt(){return Integer.parseInt(next());} nextInt {return Integer.parseInt(next());} return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next long nextLong(){return Long.parseLong(next());} nextLong {return Long.parseLong(next());} return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next double nextDouble(){return Double.parseDouble(next());} nextDouble {return Double.parseDouble(next());} return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next int[] readArray(int n){int[] a=new int[n];for (int i=0; i<n; i++) a[i]=nextInt();return a;} readArray {int[] a=new int[n];for (int i=0; i<n; i++) a[i]=nextInt();return a;} int[] a=new int[n]; a new int[n] n for (int i=0; i<n; i++) a[i]=nextInt(); int i=0; int i=0; i 0 i<n i n i++ i++ i a[i]=nextInt(); a[i]=nextInt() a[i] a i nextInt() nextInt return a; a int n n long[] readLongArray(int n){long[] a=new long[n];for (int i=0; i<n; i++) a[i]=nextLong();return a;} readLongArray {long[] a=new long[n];for (int i=0; i<n; i++) a[i]=nextLong();return a;} long[] a=new long[n]; a new long[n] n for (int i=0; i<n; i++) a[i]=nextLong(); int i=0; int i=0; i 0 i<n i n i++ i++ i a[i]=nextLong(); a[i]=nextLong() a[i] a i nextLong() nextLong return a; a int n n String nextLine(){String str = "";try{str = br.readLine();}catch (IOException e){e.printStackTrace();}return str;} nextLine {String str = "";try{str = br.readLine();}catch (IOException e){e.printStackTrace();}return str;} String str = ""; str "" try{str = br.readLine();}catch (IOException e){e.printStackTrace();} catch (IOException e){e.printStackTrace();} IOException e {e.printStackTrace();} e.printStackTrace() e.printStackTrace e {str = br.readLine();} str = br.readLine() str br.readLine() br.readLine br return str; str public class Main{
    static class FastReader{
        BufferedReader br; 
        StringTokenizer st; 
        public FastReader(){br = new BufferedReader(new InputStreamReader(System.in));} 
        String next(){while (st == null || !st.hasMoreElements()){try{st = new StringTokenizer(br.readLine());}catch (IOException  e){e.printStackTrace();}}return st.nextToken();} 
        int nextInt(){return Integer.parseInt(next());} 
        long nextLong(){return Long.parseLong(next());} 
        double nextDouble(){return Double.parseDouble(next());} 
        int[] readArray(int n){int[] a=new int[n];for (int i=0; i<n; i++) a[i]=nextInt();return a;}
        long[] readLongArray(int n){long[] a=new long[n];for (int i=0; i<n; i++) a[i]=nextLong();return a;}
        String nextLine(){String str = "";try{str = br.readLine();}catch (IOException e){e.printStackTrace();}return str;} 
    }
    static int getgcd(int n1,int n2){
        while(n1 != n2){
            if(n1 > n2) n1 -= n2;
            else n2 -= n1;
        }
        return n1;
    }
    static boolean isSorted(int[] arr, int n){
        for(int i=1;i<n;i++){
            if(arr[i]<arr[i-1]) return false;
        }
        return true;
    }
    static boolean isPrime(long n){
        if(n==2) return true;
        else if(n%2==0) return false;
        for(int i=3;i<=n/2;i+=2){
            if(n%i==0) return false;
        }
        return true;
    }
    static void printArray(int[] arr){
        for(int x:arr){
            System.out.print(x+" ");
        }
        System.out.println();
    }
    public static void main(String[] args) throws NumberFormatException, IOException {
        FastReader s=new FastReader();
        //int t = s.nextInt();
        int[] a = s.readArray(5);
        boolean test;
        //while(t>0){
            //test=true;
            if(a[0]==0) System.out.println("1");
            else if(a[1]==0) System.out.println("2");
            else if(a[2]==0) System.out.println("3");
            else if(a[3]==0) System.out.println("4");
            else if(a[4]==0) System.out.println("5");
            //t--;
       // }
    }
} public class Main{
    static class FastReader{
        BufferedReader br; 
        StringTokenizer st; 
        public FastReader(){br = new BufferedReader(new InputStreamReader(System.in));} 
        String next(){while (st == null || !st.hasMoreElements()){try{st = new StringTokenizer(br.readLine());}catch (IOException  e){e.printStackTrace();}}return st.nextToken();} 
        int nextInt(){return Integer.parseInt(next());} 
        long nextLong(){return Long.parseLong(next());} 
        double nextDouble(){return Double.parseDouble(next());} 
        int[] readArray(int n){int[] a=new int[n];for (int i=0; i<n; i++) a[i]=nextInt();return a;}
        long[] readLongArray(int n){long[] a=new long[n];for (int i=0; i<n; i++) a[i]=nextLong();return a;}
        String nextLine(){String str = "";try{str = br.readLine();}catch (IOException e){e.printStackTrace();}return str;} 
    }
    static int getgcd(int n1,int n2){
        while(n1 != n2){
            if(n1 > n2) n1 -= n2;
            else n2 -= n1;
        }
        return n1;
    }
    static boolean isSorted(int[] arr, int n){
        for(int i=1;i<n;i++){
            if(arr[i]<arr[i-1]) return false;
        }
        return true;
    }
    static boolean isPrime(long n){
        if(n==2) return true;
        else if(n%2==0) return false;
        for(int i=3;i<=n/2;i+=2){
            if(n%i==0) return false;
        }
        return true;
    }
    static void printArray(int[] arr){
        for(int x:arr){
            System.out.print(x+" ");
        }
        System.out.println();
    }
    public static void main(String[] args) throws NumberFormatException, IOException {
        FastReader s=new FastReader();
        //int t = s.nextInt();
        int[] a = s.readArray(5);
        boolean test;
        //while(t>0){
            //test=true;
            if(a[0]==0) System.out.println("1");
            else if(a[1]==0) System.out.println("2");
            else if(a[2]==0) System.out.println("3");
            else if(a[3]==0) System.out.println("4");
            else if(a[4]==0) System.out.println("5");
            //t--;
       // }
    }
} Main
import java.io.*;import java.util.*;

public class Main{
    static class FastReader{
        BufferedReader br; 
        StringTokenizer st; 
        public FastReader(){br = new BufferedReader(new InputStreamReader(System.in));} 
        String next(){while (st == null || !st.hasMoreElements()){try{st = new StringTokenizer(br.readLine());}catch (IOException  e){e.printStackTrace();}}return st.nextToken();} 
        int nextInt(){return Integer.parseInt(next());} 
        long nextLong(){return Long.parseLong(next());} 
        double nextDouble(){return Double.parseDouble(next());} 
        int[] readArray(int n){int[] a=new int[n];for (int i=0; i<n; i++) a[i]=nextInt();return a;}
        long[] readLongArray(int n){long[] a=new long[n];for (int i=0; i<n; i++) a[i]=nextLong();return a;}
        String nextLine(){String str = "";try{str = br.readLine();}catch (IOException e){e.printStackTrace();}return str;} 
    }
    static int getgcd(int n1,int n2){
        while(n1 != n2){
            if(n1 > n2) n1 -= n2;
            else n2 -= n1;
        }
        return n1;
    }
    static boolean isSorted(int[] arr, int n){
        for(int i=1;i<n;i++){
            if(arr[i]<arr[i-1]) return false;
        }
        return true;
    }
    static boolean isPrime(long n){
        if(n==2) return true;
        else if(n%2==0) return false;
        for(int i=3;i<=n/2;i+=2){
            if(n%i==0) return false;
        }
        return true;
    }
    static void printArray(int[] arr){
        for(int x:arr){
            System.out.print(x+" ");
        }
        System.out.println();
    }
    public static void main(String[] args) throws NumberFormatException, IOException {
        FastReader s=new FastReader();
        //int t = s.nextInt();
        int[] a = s.readArray(5);
        boolean test;
        //while(t>0){
            //test=true;
            if(a[0]==0) System.out.println("1");
            else if(a[1]==0) System.out.println("2");
            else if(a[2]==0) System.out.println("3");
            else if(a[3]==0) System.out.println("4");
            else if(a[4]==0) System.out.println("5");
            //t--;
       // }
    }
}