using System;

namespace ConsoleApp13
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Split(' ');
            int n = Int32.Parse(a[0]);
            int k = Int32.Parse(a[1]);
            int[] p = new int[n];
            var b = Console.ReadLine().Split(' ');
            for (int i = 0; i < n; i++)
            { 
                p[i]= Int32.Parse(b[i]);
            }
            int k1 = Array.IndexOf(p, k);
            if (k1 == n-1)
            {
                k1 = -1;
            }
            k1++;
            Console.WriteLine(p[k1]);
        }
    }
}