#include <iostream>
#include <bits/stdc++.h>

using namespace std;

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