using System;

namespace Madjionicar
{
    class Program
    {
        static void Main(string[] args)
        {
            string numb = Console.ReadLine();
            string[] numb1 = numb.Split(' ');
            int[] a = Array.ConvertAll<string, int>(numb1, int.Parse);
            int[] spil = new int[a[0]];
            int k = a[1];
            string numb2 = Console.ReadLine();
            string[] numb3 = numb2.Split(' ');
            spil = Array.ConvertAll<string, int>(numb3, int.Parse);
            int j = Array.IndexOf(spil, k);
            if(j==(a[0]-1))
            {
                j = 0;
            } else
            {
                j = j + 1;
            }
            Console.Write("{0}", spil[j]);
        }
    }
}