using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            string[] s = str.Split();
            int n = int.Parse(s[0]);
            int k = int.Parse(s[1]);
            int p = 0;
            int[] a = new int[n];
            int i = 0;
            str = Console.ReadLine();
           s = str.Split();
            while (i < n)
            {
                a[i] = int.Parse(s[i]);
                if (a[i] == k) p = i;
                i++;
            }
           
            if (p < i-1)
            {
                Console.WriteLine(a[p+1]);
            }
            else Console.WriteLine(a[0]);
           
           // Console.ReadLine();
        }
    }
}