#include <bits/stdc++.h>
using namespace std;

//      Starting Kit     (START)
typedef long long ll;
#define INF INT_MAX
#define MOD (1e9+7)

#define pii pair<int, int>
#define mp make_pair

#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vb vector<bool>
#define vs vector<string>
#define vvi vector<vi>
#define vii vector<pii>
#define pb push_back
#define print_vect(v) for (auto it : v) cout << it << " ";
//      Starting Kit     (END)




int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // INPUT
    int N, K; cin >> N >> K;
    vi p(N);

    for (int i = 0; i < N; ++i) cin >> p[i];

    // ...
    if (p[N-1] == K) cout << p[0];
    else {
        for (int i = 0; i < N; ++i)
            if (p[i] == K) {
                cout << p[i+1];
                break;
            }
    }

    return 0;
}