using System;

    class Program
    {
        static void Main(string[] args)
        {
            string[] red = Console.ReadLine().Split(' ');
            int n = Convert.ToInt32(red[0]);
            int k = Convert.ToInt32(red[1]);
            red = Console.ReadLine().Split(' ');
            int[] karte = new int[n];
            for(int i = 0;i < n;i++)
            {
                karte[i] = Convert.ToInt32(red[i]);
            }

            if (k == karte[karte.Length - 1])
            {
                Console.WriteLine(karte[0]);
            }
            else
            {
                int i = 0;
                while(i < karte.Length - 1)
                {
                    if (k == karte[i])
                    {
                        Console.WriteLine(karte[i + 1]);
                        break;
                    }
                    i++;
                }
            }
        }
    }