using System;
using System.Collections;
using System.Collections.Generic;



class HelloWorld
{ 
    

    static void Main()
    { 
        string[] s=Console.ReadLine().Split(' ');
        int n = int.Parse(s[0]);
        int k = int.Parse(s[1]);
        int[] a = new int[n];
        s=Console.ReadLine().Split(' ');
        for (int i=0;i<n;i++) a[i]=int.Parse(s[i]);
        int p = 0;
        while (a[p] != k) p++;
        if (p == n - 1) Console.WriteLine(a[0]); else Console.WriteLine(a[p] + 1);
    }
}