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

int main()
{
    int cnum, above;
    scanf("%d %d", &cnum, &above);
    int cards[cnum], id;
    for(int i = 0 ; i < cnum ; i++)
    {
        scanf(" %d",&cards[i]);
        if(cards[i] == above)
            id = i;
    }

    if(id == cnum - 1)
        printf("%d",cards[0]);
    else
        printf("%d",cards[id+1]);

    return 0;
}