#include <iostream>
#include <vector>

using namespace std;

int main() {
	int n, k, index = -1;
	cin >> n >> k;
	vector<int> karte;
	for (int i = 0; i < n; i++) {
		int karta;
		cin >> karta;
		karte.push_back(karta);
		if (karta == k) index = i;
	}
	cout << karte[(index == n - 1 ? 0 : index + 1)];
}