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

namespace trikKarte
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int n = Convert.ToInt32(s[0]);
            int k = Convert.ToInt32(s[1]);
            string[] niz = Console.ReadLine().Split();
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = Convert.ToInt32(niz[i]);
            }
            if (k == a[n - 1]) Console.Write(a[0]);
            else
            {
                int i;
                for (i = 0; i < n; i++)
                {
                    if (k == a[i]) break;
                }
                Console.Write(a[i + 1]);
            }
            Console.ReadKey();
        }
    }
}