#include <iostream>

using namespace std;

int main() {
    int n, k;
    cin>>n>>k;
    int s[n];
    for (int i = 0; i < n; i++) cin>>s[i];
    for (int i = 0; i < n-1; i++){
        if(s[i] == k){
            cout<<s[i+1];
            return 0;
        }
    }
    cout<<s[0];
    return 0;
}