import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int x1 = in.nextInt();
        int x2 = in.nextInt();
        int x3 = in.nextInt();
        int x4 = in.nextInt();
        int x5 = in.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 in = new Scanner(System.in);
        int x1 = in.nextInt();
        int x2 = in.nextInt();
        int x3 = in.nextInt();
        int x4 = in.nextInt();
        int x5 = in.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 in = new Scanner(System.in);
        int x1 = in.nextInt();
        int x2 = in.nextInt();
        int x3 = in.nextInt();
        int x4 = in.nextInt();
        int x5 = in.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 in = new Scanner(System.in);
        int x1 = in.nextInt();
        int x2 = in.nextInt();
        int x3 = in.nextInt();
        int x4 = in.nextInt();
        int x5 = in.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 in = new Scanner(System.in); in new Scanner(System.in) int x1 = in.nextInt(); x1 in.nextInt() in.nextInt in int x2 = in.nextInt(); x2 in.nextInt() in.nextInt in int x3 = in.nextInt(); x3 in.nextInt() in.nextInt in int x4 = in.nextInt(); x4 in.nextInt() in.nextInt in int x5 = in.nextInt(); x5 in.nextInt() in.nextInt in 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 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 ans 2 if (x3 == 0) {
            ans = 3;
        } else if (x4 == 0) {
            ans = 4;
        } else {
            ans = 5;
        } x3 == 0 x3 0 {
            ans = 3;
        } ans = 3 ans 3 if (x4 == 0) {
            ans = 4;
        } else {
            ans = 5;
        } x4 == 0 x4 0 {
            ans = 4;
        } ans = 4 ans 4 {
            ans = 5;
        } 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 in = new Scanner(System.in);
        int x1 = in.nextInt();
        int x2 = in.nextInt();
        int x3 = in.nextInt();
        int x4 = in.nextInt();
        int x5 = in.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 in = new Scanner(System.in);
        int x1 = in.nextInt();
        int x2 = in.nextInt();
        int x3 = in.nextInt();
        int x4 = in.nextInt();
        int x5 = in.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 in = new Scanner(System.in);
        int x1 = in.nextInt();
        int x2 = in.nextInt();
        int x3 = in.nextInt();
        int x4 = in.nextInt();
        int x5 = in.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);
    }
}
