#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <string>
#include <array>
using namespace std;
int main()
{
    int N, K, i, pi, brkarte;
    cin >> N >> K;
    int *niz = new int[N];
    for(i = 1; i <= N; i++){
    cin >> niz[i];
    int pbr = niz[N - 1];
    if(niz[i - 1] == K){
        brkarte = niz[i];
        }
    if(K == pbr){
        brkarte = niz[0];
        }
    }
    cout << brkarte;
    
}