#include <stdio.h>

#define MAX_N 20001

int main() {
    int N, K;
    int K_index;

    int spil[MAX_N];

    scanf("%d%d", &N, &K);

    for (int i = 0; i<N; i++) {
            scanf("%d", &spil[i]);
            if (spil[i] == K) K_index = i;
    }

    if (K_index == N-1) {
            printf("%d\n", spil[0]);
            return 0;
    }

    printf("%d\n", spil[K_index+1]);

    return 0;
}