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

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

    if(br == n-1)
        printf("%d",a[0]);
    else
        printf("%d",a[br+1]);
    return 0;
}