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

int a[N];


int main(){
    int n,k;
    cin>>n>>k;
    int j = -1;
    for(int i =0;i<n;i++){
        cin>>a[i];
        if(a[i]==k){
            j = i;
        }
    }
    if(j==n-1){
        cout<<a[0]<<endl;
    }
    else{
        cout<<a[j+1]<<endl;
    }
    return 0;
}