package m.shin; import java.util.Scanner; public class Con26 { public static void main(String[] args) { Scanner s = new Scanner(System.in); int[] cup = new int[3]; int N = s.nextInt() , M = s.nextInt(); cup[N-1]++; for(int i = 0;i < M;i++){ int p = s.nextInt() , q = s.nextInt(); cup[q-1] += cup[p-1]; cup[p-1] = 0; } s.close(); for(int i = 0;i < 3;i++){ if(cup[i] == 1){ System.out.println(i+1); } } } }