#include <iostream>
#include <list>
#include <iterator>

int main()
{
    unsigned short n, k;
    std::cin >> n >> k;

    std::list<unsigned short> karte;

    for (unsigned short i = 0; i < n; ++i) {
        unsigned short temp;
        std::cin >> temp;
        karte.push_back(temp);
    }


    for (std::list <unsigned short>::iterator i = karte.begin(); i != karte.end(); ++i) {
        if (*i == k) {
            if (++i != karte.end()) std::cout << *i;
            else std::cout << karte.front();
            break;
        }
        
    }


}