import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int x1 = sc.nextInt();
		int x2 = sc.nextInt();
		int x3 = sc.nextInt();
		int x4 = sc.nextInt();
		int x5 = sc.nextInt();
		if (x1 == 0) {
			System.out.println(1);
		} else if (x2 == 0) {
			System.out.println(2);
		} else if (x3 == 0) {
			System.out.println(3);
		} else if (x4 == 0) {
			System.out.println(4);
		} else {
			System.out.println(5);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int x1 = sc.nextInt();
		int x2 = sc.nextInt();
		int x3 = sc.nextInt();
		int x4 = sc.nextInt();
		int x5 = sc.nextInt();
		if (x1 == 0) {
			System.out.println(1);
		} else if (x2 == 0) {
			System.out.println(2);
		} else if (x3 == 0) {
			System.out.println(3);
		} else if (x4 == 0) {
			System.out.println(4);
		} else {
			System.out.println(5);
		}
	}
} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int x1 = sc.nextInt();
		int x2 = sc.nextInt();
		int x3 = sc.nextInt();
		int x4 = sc.nextInt();
		int x5 = sc.nextInt();
		if (x1 == 0) {
			System.out.println(1);
		} else if (x2 == 0) {
			System.out.println(2);
		} else if (x3 == 0) {
			System.out.println(3);
		} else if (x4 == 0) {
			System.out.println(4);
		} else {
			System.out.println(5);
		}
	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int x1 = sc.nextInt();
		int x2 = sc.nextInt();
		int x3 = sc.nextInt();
		int x4 = sc.nextInt();
		int x5 = sc.nextInt();
		if (x1 == 0) {
			System.out.println(1);
		} else if (x2 == 0) {
			System.out.println(2);
		} else if (x3 == 0) {
			System.out.println(3);
		} else if (x4 == 0) {
			System.out.println(4);
		} else {
			System.out.println(5);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x1 = sc.nextInt(); x1 sc.nextInt() sc.nextInt sc int x2 = sc.nextInt(); x2 sc.nextInt() sc.nextInt sc int x3 = sc.nextInt(); x3 sc.nextInt() sc.nextInt sc int x4 = sc.nextInt(); x4 sc.nextInt() sc.nextInt sc int x5 = sc.nextInt(); x5 sc.nextInt() sc.nextInt sc if (x1 == 0) {
			System.out.println(1);
		} else if (x2 == 0) {
			System.out.println(2);
		} else if (x3 == 0) {
			System.out.println(3);
		} else if (x4 == 0) {
			System.out.println(4);
		} else {
			System.out.println(5);
		} x1 == 0 x1 0 {
			System.out.println(1);
		} System.out.println(1) System.out.println System.out System System.out 1 if (x2 == 0) {
			System.out.println(2);
		} else if (x3 == 0) {
			System.out.println(3);
		} else if (x4 == 0) {
			System.out.println(4);
		} else {
			System.out.println(5);
		} x2 == 0 x2 0 {
			System.out.println(2);
		} System.out.println(2) System.out.println System.out System System.out 2 if (x3 == 0) {
			System.out.println(3);
		} else if (x4 == 0) {
			System.out.println(4);
		} else {
			System.out.println(5);
		} x3 == 0 x3 0 {
			System.out.println(3);
		} System.out.println(3) System.out.println System.out System System.out 3 if (x4 == 0) {
			System.out.println(4);
		} else {
			System.out.println(5);
		} x4 == 0 x4 0 {
			System.out.println(4);
		} System.out.println(4) System.out.println System.out System System.out 4 {
			System.out.println(5);
		} System.out.println(5) System.out.println System.out System System.out 5 String[] args args public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int x1 = sc.nextInt();
		int x2 = sc.nextInt();
		int x3 = sc.nextInt();
		int x4 = sc.nextInt();
		int x5 = sc.nextInt();
		if (x1 == 0) {
			System.out.println(1);
		} else if (x2 == 0) {
			System.out.println(2);
		} else if (x3 == 0) {
			System.out.println(3);
		} else if (x4 == 0) {
			System.out.println(4);
		} else {
			System.out.println(5);
		}
	}
} public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int x1 = sc.nextInt();
		int x2 = sc.nextInt();
		int x3 = sc.nextInt();
		int x4 = sc.nextInt();
		int x5 = sc.nextInt();
		if (x1 == 0) {
			System.out.println(1);
		} else if (x2 == 0) {
			System.out.println(2);
		} else if (x3 == 0) {
			System.out.println(3);
		} else if (x4 == 0) {
			System.out.println(4);
		} else {
			System.out.println(5);
		}
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int x1 = sc.nextInt();
		int x2 = sc.nextInt();
		int x3 = sc.nextInt();
		int x4 = sc.nextInt();
		int x5 = sc.nextInt();
		if (x1 == 0) {
			System.out.println(1);
		} else if (x2 == 0) {
			System.out.println(2);
		} else if (x3 == 0) {
			System.out.println(3);
		} else if (x4 == 0) {
			System.out.println(4);
		} else {
			System.out.println(5);
		}
	}
}
