#include <bits/stdc++.h>

int main() {

    int n,k; scanf("%d%d",&n,&k);
    int a[n];
    int pos = 0;
    for (int i = 0; i < n; ++i) {


        scanf("%d",&a[i]);
        if (a[i]==k) pos=i;
    }
    if (pos==n-1)printf("%d\n",a[0]);
    else printf("%d\n",a[pos+1]);

}