import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] inputs = br.readLine().split(" ");
        int n = Integer.parseInt(inputs[0]);
        String k = inputs[1];
        String[] splits = br.readLine().split(" ");
        for(int i = 0; i < n;i++)
        {
            if(k.equals(splits[i]))
            {
                try
                {
                    System.out.println(splits[i+1]);
                }
                catch (ArrayIndexOutOfBoundsException e)
                {
                    System.out.println(splits[0]);
                }
            }
        }
    }

}