#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, k; cin >> n >> k;
    int pos = 0;

    vector<int> schpil;
    for (int i = 0; i < n; i++) {
        int t; cin >> t;
        if (t == k) pos = i;
        schpil.push_back(t);
    }
    pos++;

    if (pos == schpil.size()) cout << schpil[0];
    else cout << schpil[pos];
}