#include <iostream>
using namespace std;

int main()
{
    int n,k,br=n+1,a = n-1;
    cin >> n;
    cin >> k;
    int matrica[n];
    for(int i=0;i<n;i++)
    {
        cin >> matrica[i];
    }
    for(int j=0;j<n;j++)
    {
        if(matrica[j] == k)
        {
            br = j+1;
        }
        if(j == br)
        {
            if(br < n)
            {
                cout << matrica[br];
            }
        }
        if(br == n)
        {
            cout << matrica[0];
        }
    }
}