#include <iostream>

int main()
{
    using namespace std;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N , K;
    cin >> N >> K;
    int first, before , now , solution;
    cin >> first;
    before = first;
    for(int i = 1; i < N; i++)
    { 
        cin >> now;
        if(before == K)
            solution = now;
        
        before = now;
    }   
    if(before == K)
        solution = first;
    

    cout << solution;
    return 0;
}