#include <iostream>

using namespace std;

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

    else if(a[n-1] == k)
        cout << a[0];
    else
        cout << a[br+1];
    return 0;
}