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

namespace ConsoleApp1
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string[] st = Console.ReadLine().Split();
            int n = int.Parse(st[0]); int k = int.Parse(st[1]);
            int[] karte = new int[n];
            st = Console.ReadLine().Split();
            for (int i = 0; i < n; i++) karte[i] = int.Parse(st[i]);
            if (k == karte[n - 1]) Console.WriteLine(karte[0]);
            else for (int i = 0; i < n; i++) if (k == karte[i])
                    {
                        Console.WriteLine(karte[i + 1]);
                        break;
                    }
            Console.ReadLine();
        }
    }
}