#include <iostream>

using namespace std;

int main()
{
    int n,k,j;
    cin>>n>>k;
    int niz[n] = {};

    for (int i=1;i<=n;i++) {
        cin>>j;
        niz[i] = j;
    }

    for (int l=1;l<=n;l++) {
        if (niz[l] == k) {
            if (l == n) {
                cout<<niz[1]<<endl;
            } else {
                cout<<niz[l+1]<<endl;
            }

        }
    }

    return 0;
}