#include<iostream>
#include<algorithm>
using namespace std;

/* run this program using the console pauser or add your own getch, system("pauser") or input loop */

int main(int argc, char** argv){

    int N, K;
    cin >>N>>K;
    int Niz[N+1];
    for(int i=0; i<N; i++){
        cin >>Niz[i];
    }
for (int i=0; i<N; i++){
    if(Niz[i] == K){
        if(K != Niz[N-1]){
            cout << Niz[i+1];
        }
    }else{ 
    cout << Niz[0];
    }
}
}