#include <stdio.h>
#include <stdlib.h>

int main()
{
    int N, K;
    scanf("%d", &N);
    scanf("%d", &K);
    int i;
    int cardsagain[N+N];
    for (i=0; i<N; i++) {
        scanf("%d", &cardsagain[i]);
        cardsagain[i+N] = cardsagain[i];
    }
    for (i=0; i<(N+N); i++) {
        if (cardsagain[i] == K) {
            printf("%d", cardsagain[i+1]);
            break;
        }
    }
    return 0;
}