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

namespace takprog
{
    class Program
    {
        static void Main(string[] args)
        {
            int t = 0;
            string[] p = Console.ReadLine().Split();
            int n = Convert.ToInt32(p[0]);
            int k = Convert.ToInt32(p[1]);
            int[] a = new int[n];
            p = Console.ReadLine().Split();
            for (int i = 0; i < n; i++)
            {
                a[i] = Convert.ToInt32(p[i]);
                if (a[i] == k)
                    t = i;
            }
            if (t == n - 1)
                Console.WriteLine(a[0]);
            else
                Console.WriteLine(a[t + 1]);
            Console.ReadLine();
        }
    }
}