import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// contest 170
		Scanner sc = new Scanner(System.in);
		// List<Integer> l = Arrays.asList(sc.nextInt().split(" "));
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		int w = sc.nextInt();
		int s = sc.nextInt();
		if (x == 0) {
			System.out.print(1);
		}
		if (y == 0) {
			System.out.print(2);
		}
		if (z == 0) {
			System.out.print(3);
		}
		if (w == 0) {
			System.out.print(4);
		}
		if (s == 0) {
			System.out.print(5);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// contest 170
		Scanner sc = new Scanner(System.in);
		// List<Integer> l = Arrays.asList(sc.nextInt().split(" "));
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		int w = sc.nextInt();
		int s = sc.nextInt();
		if (x == 0) {
			System.out.print(1);
		}
		if (y == 0) {
			System.out.print(2);
		}
		if (z == 0) {
			System.out.print(3);
		}
		if (w == 0) {
			System.out.print(4);
		}
		if (s == 0) {
			System.out.print(5);
		}
	}
} Main public static void main(String[] args) {
		// contest 170
		Scanner sc = new Scanner(System.in);
		// List<Integer> l = Arrays.asList(sc.nextInt().split(" "));
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		int w = sc.nextInt();
		int s = sc.nextInt();
		if (x == 0) {
			System.out.print(1);
		}
		if (y == 0) {
			System.out.print(2);
		}
		if (z == 0) {
			System.out.print(3);
		}
		if (w == 0) {
			System.out.print(4);
		}
		if (s == 0) {
			System.out.print(5);
		}
	} main {
		// contest 170
		Scanner sc = new Scanner(System.in);
		// List<Integer> l = Arrays.asList(sc.nextInt().split(" "));
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		int w = sc.nextInt();
		int s = sc.nextInt();
		if (x == 0) {
			System.out.print(1);
		}
		if (y == 0) {
			System.out.print(2);
		}
		if (z == 0) {
			System.out.print(3);
		}
		if (w == 0) {
			System.out.print(4);
		}
		if (s == 0) {
			System.out.print(5);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int y = sc.nextInt(); y sc.nextInt() sc.nextInt sc int z = sc.nextInt(); z sc.nextInt() sc.nextInt sc int w = sc.nextInt(); w sc.nextInt() sc.nextInt sc int s = sc.nextInt(); s sc.nextInt() sc.nextInt sc if (x == 0) {
			System.out.print(1);
		} x == 0 x 0 {
			System.out.print(1);
		} System.out.print(1) System.out.print System.out System System.out 1 if (y == 0) {
			System.out.print(2);
		} y == 0 y 0 {
			System.out.print(2);
		} System.out.print(2) System.out.print System.out System System.out 2 if (z == 0) {
			System.out.print(3);
		} z == 0 z 0 {
			System.out.print(3);
		} System.out.print(3) System.out.print System.out System System.out 3 if (w == 0) {
			System.out.print(4);
		} w == 0 w 0 {
			System.out.print(4);
		} System.out.print(4) System.out.print System.out System System.out 4 if (s == 0) {
			System.out.print(5);
		} s == 0 s 0 {
			System.out.print(5);
		} System.out.print(5) System.out.print System.out System System.out 5 String[] args args public class Main {

	public static void main(String[] args) {
		// contest 170
		Scanner sc = new Scanner(System.in);
		// List<Integer> l = Arrays.asList(sc.nextInt().split(" "));
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		int w = sc.nextInt();
		int s = sc.nextInt();
		if (x == 0) {
			System.out.print(1);
		}
		if (y == 0) {
			System.out.print(2);
		}
		if (z == 0) {
			System.out.print(3);
		}
		if (w == 0) {
			System.out.print(4);
		}
		if (s == 0) {
			System.out.print(5);
		}
	}
} public class Main {

	public static void main(String[] args) {
		// contest 170
		Scanner sc = new Scanner(System.in);
		// List<Integer> l = Arrays.asList(sc.nextInt().split(" "));
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		int w = sc.nextInt();
		int s = sc.nextInt();
		if (x == 0) {
			System.out.print(1);
		}
		if (y == 0) {
			System.out.print(2);
		}
		if (z == 0) {
			System.out.print(3);
		}
		if (w == 0) {
			System.out.print(4);
		}
		if (s == 0) {
			System.out.print(5);
		}
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// contest 170
		Scanner sc = new Scanner(System.in);
		// List<Integer> l = Arrays.asList(sc.nextInt().split(" "));
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		int w = sc.nextInt();
		int s = sc.nextInt();
		if (x == 0) {
			System.out.print(1);
		}
		if (y == 0) {
			System.out.print(2);
		}
		if (z == 0) {
			System.out.print(3);
		}
		if (w == 0) {
			System.out.print(4);
		}
		if (s == 0) {
			System.out.print(5);
		}
	}
}
