#include <iostream>

using namespace std;

int main()
{
    long long n, k, br = 0;
    cin >> n >> k;
    long long a[20000];
    for (long long i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] == k)
            br = i;
    }
    br = br + 1;
    if (br == n)
        cout << a[0];  
    else
        cout << a[br];
}