import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.*;
import java.math.*;
import java.io.*;
import java.text.*;
import java.math.BigInteger;

public class Main
{  

    //Life's a bitch
    public static boolean[] sieve(long n)
    {
        boolean[] prime = new boolean[(int)n+1];
        Arrays.fill(prime,true);
        prime[0] = false;
        prime[1] = false;
        long m = (long)Math.sqrt(n);
        for(int i=2;i<=m;i++)
        {
            if(prime[i])
            {
                for(int k=i*i;k<=n;k+=i)
                {
                    prime[k] = false;
                }
            }
        }
        return prime;
    } 

    
    static long GCD(long a,long b)
    {
        if(b==0)
        {
            return a;
        }
        return GCD(b,a%b);
    }

    static long CountCoPrimes(long n)
    {
        long res = n;
        for(int i=2;i*i<=n;i++)
        {
            if(n%i==0)
            {
                while(n%i==0)
                {
                    n/=i;
                }
                res-=res/i;
            }
        }
        if(n>1)
        {
            res-=res/n;
        }
        return res;
    }


    

    

    static boolean prime(int n)
    {
        for(int i=2;i*i<=n;i++)
        {
            if(i%2==0 ||i%3==0)
            {
                return false;
            }
        }
        return true;
    }

   


   
   
  
    public static void main(String[] args) throws IOException
    {
     
        new Main().run();
       
    }


   

    static void reverse(char[] a)
    {
        // char[] a = c.toCharArray();
        int start=0;
        int end = a.length-1;
        while(start!=end)
        {
            char temp = a[start];
            a[start] = a[end];
            a[end] = temp;
            start++;
            end--;
        }
    }

   


    
   
    Scanner in = new Scanner(System.in);
    void run() throws IOException
    {
        
        int[] a = new int[5];
        for(int i=0;i<5;i++){
            a[i] = ni();
            if(a[i]==0){
                printL(i+1);
                break;
            }
        }
        

    }



 

    

    //xor range query
    static long xor(long n)
    {

        if(n%4==0)
        {
            return n;
        }
        if(n%4==1)
        {
            return  1;
        }
        if(n%4==2)
        {
            return n+1;
        }
        return 0;
    }

    static long xor(long a,long b)
    {
        return xor(b)^xor(a-1);
    }


    

  
   
    

    
       
    

    
   
  



   

     void printL(long a)
    {
        System.out.println(a);
    }
    void printS(String s)
    {
        System.out.println(s);
    }

     void printD(Double d)
    {
        System.out.println(d);
    }
  
   
   
    static void swap(char c,char p)
    {
        char t = c;
        c = p;
        p = t;
    }

    static long max(long n,long m)
    {
        return Math.max(n,m);
    }
    static long min(long n,long m)
    {
        return Math.min(n,m);
    }

    double nd() throws IOException
    {
        return Double.parseDouble(in.next());
    }
    int ni() throws IOException
    {
        return Integer.parseInt(in.next());
    }

    long nl() throws IOException
    {
        return Long.parseLong(in.next());
    }

    String si() throws IOException
    {
        return in.next();
    }


  
   
    static int abs(int n)
    {
        return Math.abs(n);
    }

    static class Scanner 
    {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s){  br = new BufferedReader(new InputStreamReader(s));}

        public String next() throws IOException 
        {
            while (st == null || !st.hasMoreTokens()) 
            {
                st = new StringTokenizer(br.readLine());
            }
            return st.nextToken();
        }

        public int nextInt() throws IOException {return Integer.parseInt(next());}
        
        public long nextLong() throws IOException {return Long.parseLong(next());}

        public String nextLine() throws IOException {return br.readLine();}

        public boolean ready() throws IOException {return br.ready();}


    }

    
}



class Pair implements Comparable<Pair>
{
   int x,y;
    public Pair(int x,int y)
    {
        this.x = x;
        this.y = y;
    }
    public int compareTo(Pair o)
    {
        return this.y-o.y;
    }
} import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.BufferedReader; BufferedReader java.io import java.util.*; util.* java import java.math.*; math.* java import java.io.*; io.* java import java.text.*; text.* java import java.math.BigInteger; BigInteger java.math public class Main
{  

    //Life's a bitch
    public static boolean[] sieve(long n)
    {
        boolean[] prime = new boolean[(int)n+1];
        Arrays.fill(prime,true);
        prime[0] = false;
        prime[1] = false;
        long m = (long)Math.sqrt(n);
        for(int i=2;i<=m;i++)
        {
            if(prime[i])
            {
                for(int k=i*i;k<=n;k+=i)
                {
                    prime[k] = false;
                }
            }
        }
        return prime;
    } 

    
    static long GCD(long a,long b)
    {
        if(b==0)
        {
            return a;
        }
        return GCD(b,a%b);
    }

    static long CountCoPrimes(long n)
    {
        long res = n;
        for(int i=2;i*i<=n;i++)
        {
            if(n%i==0)
            {
                while(n%i==0)
                {
                    n/=i;
                }
                res-=res/i;
            }
        }
        if(n>1)
        {
            res-=res/n;
        }
        return res;
    }


    

    

    static boolean prime(int n)
    {
        for(int i=2;i*i<=n;i++)
        {
            if(i%2==0 ||i%3==0)
            {
                return false;
            }
        }
        return true;
    }

   


   
   
  
    public static void main(String[] args) throws IOException
    {
     
        new Main().run();
       
    }


   

    static void reverse(char[] a)
    {
        // char[] a = c.toCharArray();
        int start=0;
        int end = a.length-1;
        while(start!=end)
        {
            char temp = a[start];
            a[start] = a[end];
            a[end] = temp;
            start++;
            end--;
        }
    }

   


    
   
    Scanner in = new Scanner(System.in);
    void run() throws IOException
    {
        
        int[] a = new int[5];
        for(int i=0;i<5;i++){
            a[i] = ni();
            if(a[i]==0){
                printL(i+1);
                break;
            }
        }
        

    }



 

    

    //xor range query
    static long xor(long n)
    {

        if(n%4==0)
        {
            return n;
        }
        if(n%4==1)
        {
            return  1;
        }
        if(n%4==2)
        {
            return n+1;
        }
        return 0;
    }

    static long xor(long a,long b)
    {
        return xor(b)^xor(a-1);
    }


    

  
   
    

    
       
    

    
   
  



   

     void printL(long a)
    {
        System.out.println(a);
    }
    void printS(String s)
    {
        System.out.println(s);
    }

     void printD(Double d)
    {
        System.out.println(d);
    }
  
   
   
    static void swap(char c,char p)
    {
        char t = c;
        c = p;
        p = t;
    }

    static long max(long n,long m)
    {
        return Math.max(n,m);
    }
    static long min(long n,long m)
    {
        return Math.min(n,m);
    }

    double nd() throws IOException
    {
        return Double.parseDouble(in.next());
    }
    int ni() throws IOException
    {
        return Integer.parseInt(in.next());
    }

    long nl() throws IOException
    {
        return Long.parseLong(in.next());
    }

    String si() throws IOException
    {
        return in.next();
    }


  
   
    static int abs(int n)
    {
        return Math.abs(n);
    }

    static class Scanner 
    {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s){  br = new BufferedReader(new InputStreamReader(s));}

        public String next() throws IOException 
        {
            while (st == null || !st.hasMoreTokens()) 
            {
                st = new StringTokenizer(br.readLine());
            }
            return st.nextToken();
        }

        public int nextInt() throws IOException {return Integer.parseInt(next());}
        
        public long nextLong() throws IOException {return Long.parseLong(next());}

        public String nextLine() throws IOException {return br.readLine();}

        public boolean ready() throws IOException {return br.ready();}


    }

    
} Main Scanner in = new Scanner(System.in); in new Scanner(System.in) //Life's a bitch
    public static boolean[] sieve(long n)
    {
        boolean[] prime = new boolean[(int)n+1];
        Arrays.fill(prime,true);
        prime[0] = false;
        prime[1] = false;
        long m = (long)Math.sqrt(n);
        for(int i=2;i<=m;i++)
        {
            if(prime[i])
            {
                for(int k=i*i;k<=n;k+=i)
                {
                    prime[k] = false;
                }
            }
        }
        return prime;
    } sieve {
        boolean[] prime = new boolean[(int)n+1];
        Arrays.fill(prime,true);
        prime[0] = false;
        prime[1] = false;
        long m = (long)Math.sqrt(n);
        for(int i=2;i<=m;i++)
        {
            if(prime[i])
            {
                for(int k=i*i;k<=n;k+=i)
                {
                    prime[k] = false;
                }
            }
        }
        return prime;
    } boolean[] prime = new boolean[(int)n+1]; prime new boolean[(int)n+1] (int)n+1 (int)n 1 Arrays.fill(prime,true) Arrays.fill Arrays prime true prime[0] = false prime[0] prime 0 false prime[1] = false prime[1] prime 1 false long m = (long)Math.sqrt(n); m (long)Math.sqrt(n) Math.sqrt Math n for(int i=2;i<=m;i++)
        {
            if(prime[i])
            {
                for(int k=i*i;k<=n;k+=i)
                {
                    prime[k] = false;
                }
            }
        } int i=2; int i=2; i 2 i<=m i m i++ i++ i {
            if(prime[i])
            {
                for(int k=i*i;k<=n;k+=i)
                {
                    prime[k] = false;
                }
            }
        } {
            if(prime[i])
            {
                for(int k=i*i;k<=n;k+=i)
                {
                    prime[k] = false;
                }
            }
        } if(prime[i])
            {
                for(int k=i*i;k<=n;k+=i)
                {
                    prime[k] = false;
                }
            } prime[i] prime i {
                for(int k=i*i;k<=n;k+=i)
                {
                    prime[k] = false;
                }
            } for(int k=i*i;k<=n;k+=i)
                {
                    prime[k] = false;
                } int k=i*i; int k=i*i; k i*i i i k<=n k n k+=i k+=i k i {
                    prime[k] = false;
                } {
                    prime[k] = false;
                } prime[k] = false prime[k] prime k false return prime; prime long n n static long GCD(long a,long b)
    {
        if(b==0)
        {
            return a;
        }
        return GCD(b,a%b);
    } GCD {
        if(b==0)
        {
            return a;
        }
        return GCD(b,a%b);
    } if(b==0)
        {
            return a;
        } b==0 b 0 {
            return a;
        } return a; a return GCD(b,a%b); GCD(b,a%b) GCD b a%b a b long a a long b b static long CountCoPrimes(long n)
    {
        long res = n;
        for(int i=2;i*i<=n;i++)
        {
            if(n%i==0)
            {
                while(n%i==0)
                {
                    n/=i;
                }
                res-=res/i;
            }
        }
        if(n>1)
        {
            res-=res/n;
        }
        return res;
    } CountCoPrimes {
        long res = n;
        for(int i=2;i*i<=n;i++)
        {
            if(n%i==0)
            {
                while(n%i==0)
                {
                    n/=i;
                }
                res-=res/i;
            }
        }
        if(n>1)
        {
            res-=res/n;
        }
        return res;
    } long res = n; res n for(int i=2;i*i<=n;i++)
        {
            if(n%i==0)
            {
                while(n%i==0)
                {
                    n/=i;
                }
                res-=res/i;
            }
        } int i=2; int i=2; i 2 i*i<=n i*i i i n i++ i++ i {
            if(n%i==0)
            {
                while(n%i==0)
                {
                    n/=i;
                }
                res-=res/i;
            }
        } {
            if(n%i==0)
            {
                while(n%i==0)
                {
                    n/=i;
                }
                res-=res/i;
            }
        } if(n%i==0)
            {
                while(n%i==0)
                {
                    n/=i;
                }
                res-=res/i;
            } n%i==0 n%i n i 0 {
                while(n%i==0)
                {
                    n/=i;
                }
                res-=res/i;
            } while(n%i==0)
                {
                    n/=i;
                } n%i==0 n%i n i 0 {
                    n/=i;
                } n/=i n i res-=res/i res res/i res i if(n>1)
        {
            res-=res/n;
        } n>1 n 1 {
            res-=res/n;
        } res-=res/n res res/n res n return res; res long n n static boolean prime(int n)
    {
        for(int i=2;i*i<=n;i++)
        {
            if(i%2==0 ||i%3==0)
            {
                return false;
            }
        }
        return true;
    } prime {
        for(int i=2;i*i<=n;i++)
        {
            if(i%2==0 ||i%3==0)
            {
                return false;
            }
        }
        return true;
    } for(int i=2;i*i<=n;i++)
        {
            if(i%2==0 ||i%3==0)
            {
                return false;
            }
        } int i=2; int i=2; i 2 i*i<=n i*i i i n i++ i++ i {
            if(i%2==0 ||i%3==0)
            {
                return false;
            }
        } {
            if(i%2==0 ||i%3==0)
            {
                return false;
            }
        } if(i%2==0 ||i%3==0)
            {
                return false;
            } i%2==0 ||i%3==0 i%2==0 i%2 i 2 0 i%3==0 i%3 i 3 0 {
                return false;
            } return false; false return true; true int n n public static void main(String[] args) throws IOException
    {
     
        new Main().run();
       
    } main {
     
        new Main().run();
       
    } new Main().run() new Main().run new Main() String[] args args static void reverse(char[] a)
    {
        // char[] a = c.toCharArray();
        int start=0;
        int end = a.length-1;
        while(start!=end)
        {
            char temp = a[start];
            a[start] = a[end];
            a[end] = temp;
            start++;
            end--;
        }
    } reverse {
        // char[] a = c.toCharArray();
        int start=0;
        int end = a.length-1;
        while(start!=end)
        {
            char temp = a[start];
            a[start] = a[end];
            a[end] = temp;
            start++;
            end--;
        }
    } int start=0; start 0 int end = a.length-1; end a.length-1 a.length a a.length 1 while(start!=end)
        {
            char temp = a[start];
            a[start] = a[end];
            a[end] = temp;
            start++;
            end--;
        } start!=end start end {
            char temp = a[start];
            a[start] = a[end];
            a[end] = temp;
            start++;
            end--;
        } char temp = a[start]; temp a[start] a start a[start] = a[end] a[start] a start a[end] a end a[end] = temp a[end] a end temp start++ start end-- end char[] a a void run() throws IOException
    {
        
        int[] a = new int[5];
        for(int i=0;i<5;i++){
            a[i] = ni();
            if(a[i]==0){
                printL(i+1);
                break;
            }
        }
        

    } run {
        
        int[] a = new int[5];
        for(int i=0;i<5;i++){
            a[i] = ni();
            if(a[i]==0){
                printL(i+1);
                break;
            }
        }
        

    } int[] a = new int[5]; a new int[5] 5 for(int i=0;i<5;i++){
            a[i] = ni();
            if(a[i]==0){
                printL(i+1);
                break;
            }
        } int i=0; int i=0; i 0 i<5 i 5 i++ i++ i {
            a[i] = ni();
            if(a[i]==0){
                printL(i+1);
                break;
            }
        } {
            a[i] = ni();
            if(a[i]==0){
                printL(i+1);
                break;
            }
        } a[i] = ni() a[i] a i ni() ni if(a[i]==0){
                printL(i+1);
                break;
            } a[i]==0 a[i] a i 0 {
                printL(i+1);
                break;
            } printL(i+1) printL i+1 i 1 break; //xor range query
    static long xor(long n)
    {

        if(n%4==0)
        {
            return n;
        }
        if(n%4==1)
        {
            return  1;
        }
        if(n%4==2)
        {
            return n+1;
        }
        return 0;
    } xor {

        if(n%4==0)
        {
            return n;
        }
        if(n%4==1)
        {
            return  1;
        }
        if(n%4==2)
        {
            return n+1;
        }
        return 0;
    } if(n%4==0)
        {
            return n;
        } n%4==0 n%4 n 4 0 {
            return n;
        } return n; n if(n%4==1)
        {
            return  1;
        } n%4==1 n%4 n 4 1 {
            return  1;
        } return  1; 1 if(n%4==2)
        {
            return n+1;
        } n%4==2 n%4 n 4 2 {
            return n+1;
        } return n+1; n+1 n 1 return 0; 0 long n n static long xor(long a,long b)
    {
        return xor(b)^xor(a-1);
    } xor {
        return xor(b)^xor(a-1);
    } return xor(b)^xor(a-1); xor(b)^xor(a-1) xor(b) xor b xor(a-1) xor a-1 a 1 long a a long b b void printL(long a)
    {
        System.out.println(a);
    } printL {
        System.out.println(a);
    } System.out.println(a) System.out.println System.out System System.out a long a a void printS(String s)
    {
        System.out.println(s);
    } printS {
        System.out.println(s);
    } System.out.println(s) System.out.println System.out System System.out s String s s void printD(Double d)
    {
        System.out.println(d);
    } printD {
        System.out.println(d);
    } System.out.println(d) System.out.println System.out System System.out d Double d d static void swap(char c,char p)
    {
        char t = c;
        c = p;
        p = t;
    } swap {
        char t = c;
        c = p;
        p = t;
    } char t = c; t c c = p c p p = t p t char c c char p p static long max(long n,long m)
    {
        return Math.max(n,m);
    } max {
        return Math.max(n,m);
    } return Math.max(n,m); Math.max(n,m) Math.max Math n m long n n long m m static long min(long n,long m)
    {
        return Math.min(n,m);
    } min {
        return Math.min(n,m);
    } return Math.min(n,m); Math.min(n,m) Math.min Math n m long n n long m m double nd() throws IOException
    {
        return Double.parseDouble(in.next());
    } nd {
        return Double.parseDouble(in.next());
    } return Double.parseDouble(in.next()); Double.parseDouble(in.next()) Double.parseDouble Double in.next() in.next in int ni() throws IOException
    {
        return Integer.parseInt(in.next());
    } ni {
        return Integer.parseInt(in.next());
    } return Integer.parseInt(in.next()); Integer.parseInt(in.next()) Integer.parseInt Integer in.next() in.next in long nl() throws IOException
    {
        return Long.parseLong(in.next());
    } nl {
        return Long.parseLong(in.next());
    } return Long.parseLong(in.next()); Long.parseLong(in.next()) Long.parseLong Long in.next() in.next in String si() throws IOException
    {
        return in.next();
    } si {
        return in.next();
    } return in.next(); in.next() in.next in static int abs(int n)
    {
        return Math.abs(n);
    } abs {
        return Math.abs(n);
    } return Math.abs(n); Math.abs(n) Math.abs Math n int n n static class Scanner 
    {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s){  br = new BufferedReader(new InputStreamReader(s));}

        public String next() throws IOException 
        {
            while (st == null || !st.hasMoreTokens()) 
            {
                st = new StringTokenizer(br.readLine());
            }
            return st.nextToken();
        }

        public int nextInt() throws IOException {return Integer.parseInt(next());}
        
        public long nextLong() throws IOException {return Long.parseLong(next());}

        public String nextLine() throws IOException {return br.readLine();}

        public boolean ready() throws IOException {return br.ready();}


    } Scanner StringTokenizer st; st BufferedReader br; br public Scanner(InputStream s){  br = new BufferedReader(new InputStreamReader(s));} Scanner {  br = new BufferedReader(new InputStreamReader(s));} br = new BufferedReader(new InputStreamReader(s)) br new BufferedReader(new InputStreamReader(s)) InputStream s s public String next() throws IOException 
        {
            while (st == null || !st.hasMoreTokens()) 
            {
                st = new StringTokenizer(br.readLine());
            }
            return st.nextToken();
        } next {
            while (st == null || !st.hasMoreTokens()) 
            {
                st = new StringTokenizer(br.readLine());
            }
            return st.nextToken();
        } while (st == null || !st.hasMoreTokens()) 
            {
                st = new StringTokenizer(br.readLine());
            } st == null || !st.hasMoreTokens() st == null st null !st.hasMoreTokens() st.hasMoreTokens() st.hasMoreTokens st {
                st = new StringTokenizer(br.readLine());
            } st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st public int nextInt() throws IOException {return Integer.parseInt(next());} nextInt {return Integer.parseInt(next());} return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next public long nextLong() throws IOException {return Long.parseLong(next());} nextLong {return Long.parseLong(next());} return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next public String nextLine() throws IOException {return br.readLine();} nextLine {return br.readLine();} return br.readLine(); br.readLine() br.readLine br public boolean ready() throws IOException {return br.ready();} ready {return br.ready();} return br.ready(); br.ready() br.ready br class Pair implements Comparable<Pair>
{
   int x,y;
    public Pair(int x,int y)
    {
        this.x = x;
        this.y = y;
    }
    public int compareTo(Pair o)
    {
        return this.y-o.y;
    }
} Pair int x x y; y public Pair(int x,int y)
    {
        this.x = x;
        this.y = y;
    } Pair {
        this.x = x;
        this.y = y;
    } this.x = x this.x this this.x x this.y = y this.y this this.y y int x x int y y public int compareTo(Pair o)
    {
        return this.y-o.y;
    } compareTo {
        return this.y-o.y;
    } return this.y-o.y; this.y-o.y this.y this this.y o.y o o.y Pair o o Comparable public class Main
{  

    //Life's a bitch
    public static boolean[] sieve(long n)
    {
        boolean[] prime = new boolean[(int)n+1];
        Arrays.fill(prime,true);
        prime[0] = false;
        prime[1] = false;
        long m = (long)Math.sqrt(n);
        for(int i=2;i<=m;i++)
        {
            if(prime[i])
            {
                for(int k=i*i;k<=n;k+=i)
                {
                    prime[k] = false;
                }
            }
        }
        return prime;
    } 

    
    static long GCD(long a,long b)
    {
        if(b==0)
        {
            return a;
        }
        return GCD(b,a%b);
    }

    static long CountCoPrimes(long n)
    {
        long res = n;
        for(int i=2;i*i<=n;i++)
        {
            if(n%i==0)
            {
                while(n%i==0)
                {
                    n/=i;
                }
                res-=res/i;
            }
        }
        if(n>1)
        {
            res-=res/n;
        }
        return res;
    }


    

    

    static boolean prime(int n)
    {
        for(int i=2;i*i<=n;i++)
        {
            if(i%2==0 ||i%3==0)
            {
                return false;
            }
        }
        return true;
    }

   


   
   
  
    public static void main(String[] args) throws IOException
    {
     
        new Main().run();
       
    }


   

    static void reverse(char[] a)
    {
        // char[] a = c.toCharArray();
        int start=0;
        int end = a.length-1;
        while(start!=end)
        {
            char temp = a[start];
            a[start] = a[end];
            a[end] = temp;
            start++;
            end--;
        }
    }

   


    
   
    Scanner in = new Scanner(System.in);
    void run() throws IOException
    {
        
        int[] a = new int[5];
        for(int i=0;i<5;i++){
            a[i] = ni();
            if(a[i]==0){
                printL(i+1);
                break;
            }
        }
        

    }



 

    

    //xor range query
    static long xor(long n)
    {

        if(n%4==0)
        {
            return n;
        }
        if(n%4==1)
        {
            return  1;
        }
        if(n%4==2)
        {
            return n+1;
        }
        return 0;
    }

    static long xor(long a,long b)
    {
        return xor(b)^xor(a-1);
    }


    

  
   
    

    
       
    

    
   
  



   

     void printL(long a)
    {
        System.out.println(a);
    }
    void printS(String s)
    {
        System.out.println(s);
    }

     void printD(Double d)
    {
        System.out.println(d);
    }
  
   
   
    static void swap(char c,char p)
    {
        char t = c;
        c = p;
        p = t;
    }

    static long max(long n,long m)
    {
        return Math.max(n,m);
    }
    static long min(long n,long m)
    {
        return Math.min(n,m);
    }

    double nd() throws IOException
    {
        return Double.parseDouble(in.next());
    }
    int ni() throws IOException
    {
        return Integer.parseInt(in.next());
    }

    long nl() throws IOException
    {
        return Long.parseLong(in.next());
    }

    String si() throws IOException
    {
        return in.next();
    }


  
   
    static int abs(int n)
    {
        return Math.abs(n);
    }

    static class Scanner 
    {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s){  br = new BufferedReader(new InputStreamReader(s));}

        public String next() throws IOException 
        {
            while (st == null || !st.hasMoreTokens()) 
            {
                st = new StringTokenizer(br.readLine());
            }
            return st.nextToken();
        }

        public int nextInt() throws IOException {return Integer.parseInt(next());}
        
        public long nextLong() throws IOException {return Long.parseLong(next());}

        public String nextLine() throws IOException {return br.readLine();}

        public boolean ready() throws IOException {return br.ready();}


    }

    
} public class Main
{  

    //Life's a bitch
    public static boolean[] sieve(long n)
    {
        boolean[] prime = new boolean[(int)n+1];
        Arrays.fill(prime,true);
        prime[0] = false;
        prime[1] = false;
        long m = (long)Math.sqrt(n);
        for(int i=2;i<=m;i++)
        {
            if(prime[i])
            {
                for(int k=i*i;k<=n;k+=i)
                {
                    prime[k] = false;
                }
            }
        }
        return prime;
    } 

    
    static long GCD(long a,long b)
    {
        if(b==0)
        {
            return a;
        }
        return GCD(b,a%b);
    }

    static long CountCoPrimes(long n)
    {
        long res = n;
        for(int i=2;i*i<=n;i++)
        {
            if(n%i==0)
            {
                while(n%i==0)
                {
                    n/=i;
                }
                res-=res/i;
            }
        }
        if(n>1)
        {
            res-=res/n;
        }
        return res;
    }


    

    

    static boolean prime(int n)
    {
        for(int i=2;i*i<=n;i++)
        {
            if(i%2==0 ||i%3==0)
            {
                return false;
            }
        }
        return true;
    }

   


   
   
  
    public static void main(String[] args) throws IOException
    {
     
        new Main().run();
       
    }


   

    static void reverse(char[] a)
    {
        // char[] a = c.toCharArray();
        int start=0;
        int end = a.length-1;
        while(start!=end)
        {
            char temp = a[start];
            a[start] = a[end];
            a[end] = temp;
            start++;
            end--;
        }
    }

   


    
   
    Scanner in = new Scanner(System.in);
    void run() throws IOException
    {
        
        int[] a = new int[5];
        for(int i=0;i<5;i++){
            a[i] = ni();
            if(a[i]==0){
                printL(i+1);
                break;
            }
        }
        

    }



 

    

    //xor range query
    static long xor(long n)
    {

        if(n%4==0)
        {
            return n;
        }
        if(n%4==1)
        {
            return  1;
        }
        if(n%4==2)
        {
            return n+1;
        }
        return 0;
    }

    static long xor(long a,long b)
    {
        return xor(b)^xor(a-1);
    }


    

  
   
    

    
       
    

    
   
  



   

     void printL(long a)
    {
        System.out.println(a);
    }
    void printS(String s)
    {
        System.out.println(s);
    }

     void printD(Double d)
    {
        System.out.println(d);
    }
  
   
   
    static void swap(char c,char p)
    {
        char t = c;
        c = p;
        p = t;
    }

    static long max(long n,long m)
    {
        return Math.max(n,m);
    }
    static long min(long n,long m)
    {
        return Math.min(n,m);
    }

    double nd() throws IOException
    {
        return Double.parseDouble(in.next());
    }
    int ni() throws IOException
    {
        return Integer.parseInt(in.next());
    }

    long nl() throws IOException
    {
        return Long.parseLong(in.next());
    }

    String si() throws IOException
    {
        return in.next();
    }


  
   
    static int abs(int n)
    {
        return Math.abs(n);
    }

    static class Scanner 
    {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s){  br = new BufferedReader(new InputStreamReader(s));}

        public String next() throws IOException 
        {
            while (st == null || !st.hasMoreTokens()) 
            {
                st = new StringTokenizer(br.readLine());
            }
            return st.nextToken();
        }

        public int nextInt() throws IOException {return Integer.parseInt(next());}
        
        public long nextLong() throws IOException {return Long.parseLong(next());}

        public String nextLine() throws IOException {return br.readLine();}

        public boolean ready() throws IOException {return br.ready();}


    }

    
} Main
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.*;
import java.math.*;
import java.io.*;
import java.text.*;
import java.math.BigInteger;

public class Main
{  

    //Life's a bitch
    public static boolean[] sieve(long n)
    {
        boolean[] prime = new boolean[(int)n+1];
        Arrays.fill(prime,true);
        prime[0] = false;
        prime[1] = false;
        long m = (long)Math.sqrt(n);
        for(int i=2;i<=m;i++)
        {
            if(prime[i])
            {
                for(int k=i*i;k<=n;k+=i)
                {
                    prime[k] = false;
                }
            }
        }
        return prime;
    } 

    
    static long GCD(long a,long b)
    {
        if(b==0)
        {
            return a;
        }
        return GCD(b,a%b);
    }

    static long CountCoPrimes(long n)
    {
        long res = n;
        for(int i=2;i*i<=n;i++)
        {
            if(n%i==0)
            {
                while(n%i==0)
                {
                    n/=i;
                }
                res-=res/i;
            }
        }
        if(n>1)
        {
            res-=res/n;
        }
        return res;
    }


    

    

    static boolean prime(int n)
    {
        for(int i=2;i*i<=n;i++)
        {
            if(i%2==0 ||i%3==0)
            {
                return false;
            }
        }
        return true;
    }

   


   
   
  
    public static void main(String[] args) throws IOException
    {
     
        new Main().run();
       
    }


   

    static void reverse(char[] a)
    {
        // char[] a = c.toCharArray();
        int start=0;
        int end = a.length-1;
        while(start!=end)
        {
            char temp = a[start];
            a[start] = a[end];
            a[end] = temp;
            start++;
            end--;
        }
    }

   


    
   
    Scanner in = new Scanner(System.in);
    void run() throws IOException
    {
        
        int[] a = new int[5];
        for(int i=0;i<5;i++){
            a[i] = ni();
            if(a[i]==0){
                printL(i+1);
                break;
            }
        }
        

    }



 

    

    //xor range query
    static long xor(long n)
    {

        if(n%4==0)
        {
            return n;
        }
        if(n%4==1)
        {
            return  1;
        }
        if(n%4==2)
        {
            return n+1;
        }
        return 0;
    }

    static long xor(long a,long b)
    {
        return xor(b)^xor(a-1);
    }


    

  
   
    

    
       
    

    
   
  



   

     void printL(long a)
    {
        System.out.println(a);
    }
    void printS(String s)
    {
        System.out.println(s);
    }

     void printD(Double d)
    {
        System.out.println(d);
    }
  
   
   
    static void swap(char c,char p)
    {
        char t = c;
        c = p;
        p = t;
    }

    static long max(long n,long m)
    {
        return Math.max(n,m);
    }
    static long min(long n,long m)
    {
        return Math.min(n,m);
    }

    double nd() throws IOException
    {
        return Double.parseDouble(in.next());
    }
    int ni() throws IOException
    {
        return Integer.parseInt(in.next());
    }

    long nl() throws IOException
    {
        return Long.parseLong(in.next());
    }

    String si() throws IOException
    {
        return in.next();
    }


  
   
    static int abs(int n)
    {
        return Math.abs(n);
    }

    static class Scanner 
    {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s){  br = new BufferedReader(new InputStreamReader(s));}

        public String next() throws IOException 
        {
            while (st == null || !st.hasMoreTokens()) 
            {
                st = new StringTokenizer(br.readLine());
            }
            return st.nextToken();
        }

        public int nextInt() throws IOException {return Integer.parseInt(next());}
        
        public long nextLong() throws IOException {return Long.parseLong(next());}

        public String nextLine() throws IOException {return br.readLine();}

        public boolean ready() throws IOException {return br.ready();}


    }

    
}



class Pair implements Comparable<Pair>
{
   int x,y;
    public Pair(int x,int y)
    {
        this.x = x;
        this.y = y;
    }
    public int compareTo(Pair o)
    {
        return this.y-o.y;
    }
}