using System;
using System.Collections.Generic;
using System.Linq;


class Project
{
    static void Main()
    {
        string[] s = Console.ReadLine().Split();
        int n = int.Parse(s[0]);
        int k = int.Parse(s[1]);
        List<int> a = new List<int>(n);
        s = Console.ReadLine().Split();
        for (int i = 0; i < n; i++)
        {
            a.Add(int.Parse(s[i]));
        }

        if(a.Count() == 2)
        {
            if(a[0] != k) { Console.WriteLine(a[0]); return; }
            else { Console.WriteLine(a[1]); return; }
        }
        else
        {
            int j = a.FindIndex(x => x == k);
            if(j == n - 1) { Console.WriteLine(a[0]); }
            else { Console.WriteLine(a[j + 1]); }
        }
    }
}