#include <iostream>
#define forn(i, n) for (int i = 0; i < n; i++)
using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    int a[n];
    forn(i, n) cin >> a[i];
    forn(i, n) if (a[i] == k) cout << a[(i + 1) % n] << endl;
    #ifdef CHUNGUS
    system("pause");
    #endif
}