#include<iostream>
#include<cmath>

using namespace std;

int main(){

int n, k, x[100], karta, i;

cin>>n>>k;
int* ptr = (int*) malloc(n*sizeof(int));
for(i = 0; i<n; i++){
    cin>>ptr[i];
}

for(i = 0; i<n; i++){
    if(x[i] == k){
        if(i == n-1){
            karta = ptr[0];
        }else{
            karta = ptr[i+1];
        }
    }
}
cout<<karta;









return 0;

}