#include <iostream>

using namespace std;


int main()
{


    int n, k, x, y = -1, e0;
    cin>>n>>k;

    for(int i=0;i<n;i++)
    {

        cin >> x;
        if(i==0)
            e0 = x;

        if(x == k && i != n-1)
        {
            cin >> y;
            i++;
        }

    }



    if(y == -1)
        y = e0;

    cout << y;




    return 0;
}