#include <iostream>

using namespace std;

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