using System;
using System.Collections.Generic;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] p = Console.ReadLine().Split();
            int n = Convert.ToInt32(p[0]);
            int k = Convert.ToInt32(p[1]);
            String[] p1 = Console.ReadLine().Split();
            List<int> a = new List<int>();
            for (int i = 0; i < n; i++)
                a.Add(Convert.ToInt32(p1[i]));
            int l = a.IndexOf(k);
            if (l == n - 1)
                Console.WriteLine(a[0]);
            else
                Console.WriteLine(a[l + 1]);
        }
    }
}