#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
ll moda=1000000007;
typedef vector<ll> vl1;
typedef vector<vl1> vl2;
typedef vector<string> vst1;

struct struka
{ll val; ll ind;};
typedef vector<struka> vs1;

bool compa(struka& a, struka& b)
{ if(a.val==b.val) return a.ind<b.ind;
  return a.val<b.val;
}

ll lova(vl1&  veka, ll dole, ll gore, ll val)
{ ll sred;
  while(dole<=gore)
  {sred=(gore+dole)/2;
   if(veka[sred]>=val) gore=sred-1;// real condition !
   else dole=sred+1;
  }
 return dole;
}

ll gcd(ll a,ll b)
{ll t;
  while (b)
  { t= b;
    b = a % b;
    a = t;
  }
return a;
}

ll fast_pow(ll a, ll p)
{ ll res = 1;
  while (p)
   { if ( (p &1) == 0) { a = (a * a); p >>=1; }
     else {  res *=  a;   p--; }
   }
  return res;
}

void radi(ll& q)
{ ll i, j, k, kn, m, n, p, t, l, r, x, y, z, a, b, c, d;
  ll val, pos, tmp, suma, maxa, mina, naso, num;
  string str1;
  char ch1;
  cin>>n>>val;
  vl1 niz(n+1);
  for(i=1;i<=n;i++)
   { cin>>num;
     niz[i]=num;
     if(num==val) k=i;
   }
  k++;
  if(k>n) k=1;
  naso=niz[k];
  cout<<naso<<'\n';
}

int main()
{ /*
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(nullptr);
  cout<<fixed<<setprecision(15);
  */

  ll t, q;
  //cin>>t;
  t=1;
  for(q=1;q<=t;q++)
   { // cout<<"Case #"<<q<<": ";
     radi(q);
   }
  return 0;
}
/*
2 2
2 1

5 3
5 4 1 2 3

*/