program magija;
var n,k,i,x:integer;
a:array [1..32000] of integer;

begin
read(n,k);
x:=0;
for i:=1 to n do
read(a[i]);
if a[n]=k then x:=a[1]
else for i:=1 to n-1 do
if a[i]=k then x:=a[i+1];
write(x);
end.