using System;

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