#include <iostream>
#include<vector>


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

    std::vector<long long> karte;

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



    for (auto it = karte.begin(); it != karte.end(); ++it)
    {
        if (*it == k) {
            if (it + 1 == karte.end()) {
                std::cout << karte[0];
                break;
            }
            else
                it = it + 1;
                std::cout << *it;
                break;
        }
        
    }
    return 0;
}