#include <iostream>

using namespace std;

int main ()
{
    int n,k,x,y,b=0;
    cin>>n>>k;
    cin>>x;
    if(x==k){
        cin>>y;
        cout<<y;}
    else{
        for (int i=1;i<n;i++)
            {cin>>y;
            if(y==k&&i!=n-1&&b==0)
                b++;
            if(y==k&&i==n-1&&b==0){
                cout<<x;break;}
            if(b==1){
                cout<<y;break;}}}
    return 0;
}