#include <bits/stdc++.h>

#define IOS {ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
#define MAXN 20005

using namespace std;

int n, k ;
int a[MAXN] ;

void solve()
{
    cin >> n >> k ;

    for(int i = 1 ; i <= n ; i++)cin >> a[i] ;

    for(int i = 1 ; i <= n ; i++)
    {
        if(a[i] == k)
        {
            if(i == n)cout << a[1] << endl ;
            else cout << a[i+1] << endl ;
        }
    }
}

int main()
{
    IOS ;

    solve();
}