#include #include #include #include #include using namespace std; using namespace atcoder; using ll = long long; using mint = modint998244353; using vi = vector; using vvi = vector; using vvvi = vector; using vll = vector; using vvll = vector; using vvvll = vector; using vmi = vector; using vvmi = vector; using vvvmi = vector; #define all(a) (a).begin(), (a).end() #define rep2(i, m, n) for (int i = (m); i < (n); ++i) #define rep(i, n) rep2(i, 0, n) #define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i) #define drep(i, n) drep2(i, n, 0) int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int n; ll x; cin >> n >> x; vi a(n), cnt(n+1, 0); rep(i, n){ cin >> a[i]; int m = (a[i] < n ? a[i] : n); cnt[m]++; } if(x <= n){ cout << a[x-1] << endl; return 0; } set st; rep(i, n+1){ if(cnt[i] == 0)st.insert(i); } vi b(n+1); rep(i, n+1){ b[i] = *st.begin(); cnt[b[i]]++; st.erase(b[i]); if(i == n)break; cnt[a[i]]--; if(cnt[a[i]] == 0)st.insert(a[i]); } ll base = x - n; cout << b[(base - 1) % (n+1)] << endl; return 0; }