#include <bits/stdc++.h>

using namespace std;

#define MAX 100000

int main()
{
    long long int n,k,a[MAX];
    cin >> n >> k;
    for(long long int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    for(long long int i = 0; i < n; ++i)
    {
        if(k == a[i] && i < n-1)
        {
            cout << a[i+1];
        }
        else if(a[i] == k && i == n-1)
        {
            cout << a[0];
        }
    }
    return 0;
}