#include<bits/stdc++.h>
using namespace std;
#define MAXN 500007
#define ll long long
int a[MAXN];
int solve(int n, int k)
{
    int ix=find(a,a+n,k)-a;
    if(ix==n-1)
    {
        cout<<a[0]<<endl;
    }
    else
    {
        cout<<a[ix+1]<<endl;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int t=1;;
    int n,k;
    for(int i=0;i<t;i++)
    {
        cin>>n>>k;
        for(int j=0;j<n;j++)
        {
            cin>>a[j];
        }
        solve(n,k);
    }
}