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

namespace ConsoleApplication11
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> spil = new List<int>();
            string pocetak = Console.ReadLine();
            int n = Int32.Parse(pocetak.Split(' ')[0]);
            int broj = Int32.Parse(pocetak.Split(' ')[1]);

            string ulaz = Console.ReadLine();

            foreach (string objekat in ulaz.Split(' ','\r','\n')) { spil.Add(Int32.Parse(objekat)); }

            if (spil.FindIndex(x => x == broj) >= n - 1)
            {
                int resenje = spil[0];
                Console.WriteLine(resenje);
            }
            else
            {
                int resenje = spil[spil.FindIndex(x => x == broj) + 1];
                Console.WriteLine(resenje);
            }
            Console.ReadKey();
        }
    }
}