import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int x1,x2,x3,x4,x5,ans=0;
        x1=scan.nextInt();
        x2=scan.nextInt();
        x3=scan.nextInt();
        x4=scan.nextInt();
        x5=scan.nextInt();
        if(x1==0) ans=1;
         if(x2==0) ans=2;
          if(x3==0) ans=3;
           if(x4==0) ans=4;
            if(x5==0) ans=5;
        System.out.println(ans);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int x1,x2,x3,x4,x5,ans=0;
        x1=scan.nextInt();
        x2=scan.nextInt();
        x3=scan.nextInt();
        x4=scan.nextInt();
        x5=scan.nextInt();
        if(x1==0) ans=1;
         if(x2==0) ans=2;
          if(x3==0) ans=3;
           if(x4==0) ans=4;
            if(x5==0) ans=5;
        System.out.println(ans);
    }
} Main public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int x1,x2,x3,x4,x5,ans=0;
        x1=scan.nextInt();
        x2=scan.nextInt();
        x3=scan.nextInt();
        x4=scan.nextInt();
        x5=scan.nextInt();
        if(x1==0) ans=1;
         if(x2==0) ans=2;
          if(x3==0) ans=3;
           if(x4==0) ans=4;
            if(x5==0) ans=5;
        System.out.println(ans);
    } main {
        Scanner scan = new Scanner(System.in);
        int x1,x2,x3,x4,x5,ans=0;
        x1=scan.nextInt();
        x2=scan.nextInt();
        x3=scan.nextInt();
        x4=scan.nextInt();
        x5=scan.nextInt();
        if(x1==0) ans=1;
         if(x2==0) ans=2;
          if(x3==0) ans=3;
           if(x4==0) ans=4;
            if(x5==0) ans=5;
        System.out.println(ans);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int x1 x1 x2 x2 x3 x3 x4 x4 x5 x5 ans=0; ans 0 x1=scan.nextInt() x1 scan.nextInt() scan.nextInt scan x2=scan.nextInt() x2 scan.nextInt() scan.nextInt scan x3=scan.nextInt() x3 scan.nextInt() scan.nextInt scan x4=scan.nextInt() x4 scan.nextInt() scan.nextInt scan x5=scan.nextInt() x5 scan.nextInt() scan.nextInt scan if(x1==0) ans=1; x1==0 x1 0 ans=1 ans 1 if(x2==0) ans=2; x2==0 x2 0 ans=2 ans 2 if(x3==0) ans=3; x3==0 x3 0 ans=3 ans 3 if(x4==0) ans=4; x4==0 x4 0 ans=4 ans 4 if(x5==0) ans=5; x5==0 x5 0 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) throws Exception {
        Scanner scan = new Scanner(System.in);
        int x1,x2,x3,x4,x5,ans=0;
        x1=scan.nextInt();
        x2=scan.nextInt();
        x3=scan.nextInt();
        x4=scan.nextInt();
        x5=scan.nextInt();
        if(x1==0) ans=1;
         if(x2==0) ans=2;
          if(x3==0) ans=3;
           if(x4==0) ans=4;
            if(x5==0) ans=5;
        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int x1,x2,x3,x4,x5,ans=0;
        x1=scan.nextInt();
        x2=scan.nextInt();
        x3=scan.nextInt();
        x4=scan.nextInt();
        x5=scan.nextInt();
        if(x1==0) ans=1;
         if(x2==0) ans=2;
          if(x3==0) ans=3;
           if(x4==0) ans=4;
            if(x5==0) ans=5;
        System.out.println(ans);
    }
} Main
import java.util.*;

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