#include <iostream>

using namespace std;

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