//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <iomanip> 
#include <map>
#include <string>
#include <list>
#include <unordered_set>

#define f(n) for (int i = 0; i < n; i++)
#define f0(n) for (int j = 0; j < n; j++)

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n, k, p = 0;
    cin >> n >> k;
    vector<int> a(n);
    f(n)
    {
        cin >> a[i];
    }
    f(n - 1)
    {
        if (a[i] == k) p = a[i + 1];
    }
    if (a[n - 1] == k) p = a[0];
    cout << p;
}