using System;
//using System.IO;
//using System.Text;

namespace Madionicar
{
    internal class Program
    {
        static void Main(string[] args)
        {
            //Console.SetIn(new StreamReader(Console.OpenStandardInput(), Encoding.UTF8, false, 960008));
            string[] values = Console.ReadLine().Split(' ');
            int n = Convert.ToInt32(values[0]);
            int k = Convert.ToInt32(values[1]);
            int[] karte = new int[n];
            char c = (char)Console.Read();
            /*for (int i = 0; i < n; i++)
            {
                do {
                    c = (char)Console.Read();
                    if (c != ' ' && c != '\r')
                    {
                        karte[i] = karte[i] * 10 + Convert.ToInt32(Convert.ToString(c));
                    }
                } while (c != ' ' && c != '\r');
            }
            for(int i = 0;i < n; i++)
            {
                if (karte[i] == k)
                {
                    if (i + 1 != n)
                    {
                        Console.Write(karte[i + 1]);
                    }
                    else
                    {
                        Console.Write(karte[0]);
                    }
                    break;
                }
            }*/
        }
    }
}