using System;

namespace Takmicenje20
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] r = Console.ReadLine().Split();
            int n = int.Parse(r[0]);
            int k = int.Parse(r[1]);
            int[] a = new int[n];
            int ind = 0;
            r = Console.ReadLine().Split();
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(r[i]);
                if (a[i] == k) ind = i;
            }
            if (ind == n - 1) Console.WriteLine(a[0]);
            else Console.WriteLine(a[ind + 1]);
            Console.ReadLine();
        }
    }
}