using System;
using System.IO;
using System.Linq;

class ConsoleApp21
{
    static void Main()
    {
        int k=0;
        var b = Console.ReadLine().Split();
        int a = int.Parse(b[0]);
         int x = int.Parse(b[1]);
        int[] y = new int[a];
        var c = Console.ReadLine().Split();
        for (int i=0;i<a;i++)
        {
            y[i] = int.Parse(c[i]);
            if(y[i]==x)
            {
                k = i;
            }
        }
        if(k<a-1)
        {
            Console.WriteLine(y[k +1]);
        }
        else
        {
            Console.WriteLine(y[0]);
        }

    }
}