using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.SymbolStore;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Net.WebSockets;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Schema;
using System.Numerics;
//using System.Data;
//using System.Drawing;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split();
            int n = int.Parse(s[0]);
            int k = int.Parse(s[1]);
            var a = Console.ReadLine().Trim().Split().Select(int.Parse).ToList();
            for (int i = 0; i < n; i++)
            {
                if (a[i] == k)
                {
                    if (i == n - 1)
                    {
                        Console.WriteLine(a[0]);
                    }
                    else Console.WriteLine(a[i + 1]);
                    return;
                }
            }
        }
    }
}