using System;

namespace zadatak_2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int n = int.Parse(s[0]);
            int k = int.Parse(s[1]);
            int[] a = new int[n];
            int b = 0;
            s = Console.ReadLine().Split();
            for (int i = 0; i < n; i++) { 
                a[i] = int.Parse(s[i]);
            }
            int j = 0;
            while (j < n) {
                if (j != n - 1) { 
                    if (a[j] == k)
                        b = a[j + 1];
                }
                else
                {
                    if (a[j] == k)
                        b = a[0];
                }
                j++;
            }
            Console.WriteLine(b);
        }
    }
}