#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0)

using namespace std;

using namespace __gnu_pbds;

int main()
{

    FAST;

    int n, k; cin >> n >> k;
    int s[n];
    int e;
    for(int i = 0; i < n; i++) cin >> s[i];

    for(int i = 0; i < n; i++){
        if(s[i] == k){
            if(i == n-1){
                e = s[0];
            }
            else{
                e = s[i+1];
            }
            break;
        }
    }

    cout << e << endl;
    return 0;
}