#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)
#define L(x) (sizeof(x) / sizeof(*x))
#define ff(i,a,b) for(int (i) = (a); (i)<(b);(i)++)

using namespace std;

using namespace __gnu_pbds;

int indexOf(int a[],int n,int t){
    ff(i,0,n){
        if(a[i]== t){
            return i;
        }
    }
}
int main()
{
    FAST;

    int n,k;
    cin>>n>>k;
    int p[n];
    ff(i,0,n)cin>>p[i];
    int index = indexOf(p,n,k),karta;
    if(index == n-1){
        karta = p[0];
    }else{
        karta = p[index+1];
    }
    cout<<karta<<endl;
    return 0;
}