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

int main()
{
    int n,k,p;
    scanf("%d%d",&n,&k);
    int a[n];
    int i;
    for(i=0;i<n;i++)
    {
        int s;
        scanf("%d",&s);
        a[i]=s;
        if(s==k)
            p=i;
    }
    if(p==n-1)
    {
        printf("%d",a[0]);
    }
    else
    {
        printf("%d",a[p+1]);
    }
}