using System;

namespace ConsoleApp39
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s1 = Console.ReadLine().Split(' ');
            int n = int.Parse(s1[0]);
            int k = int.Parse(s1[1]);
            int[] a = new int[n];
            string[] s2 = Console.ReadLine().Split(' ');

            for (int i = 0; i < n; i++)
                a[i] = int.Parse(s2[i]);

            if (a[n - 1] == k)
            {
                Console.WriteLine(a[0]);
                return;
            }

            int m = 0;
            for (int i = 0; i < n; i++)
            {
                if (a[i] == k)
                {
                    m = a[i + 1];
                    break;
                }
            }
            Console.WriteLine(m);
        }
    }
}