import java.util.Scanner; public class A000481 { public static void main(String[] args) { Scanner s = new Scanner(System.in); for(int i=0;i<9;i++) { if(s.nextInt()-i!=1) { System.out.println(i+1); break; } if(i==8)System.out.println(10); } s.close(); } }