using System;

namespace zadaci
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string[] temp1 = Console.ReadLine().Split(' ');
            int N = Convert.ToInt32(temp1[0]);
            int K = Convert.ToInt32(temp1[1]);

            int y = 0;
            int[] spil = new int[N];
            temp1 = Console.ReadLine().Split(' ');
            for (int i = 0; i < N; i++)
            {
                spil[i] = Convert.ToInt32(temp1[i]);
                if (spil[i] == K)
                    y = i;
            }
           
            if (y == N - 1)
                Console.WriteLine(spil[0]);
            else
                Console.WriteLine(spil[y + 1]);
            //Console.ReadLine();
        }
    }
}