#The solution in Python3 is as follows:
n,m=map(int,input().split())
a=list(map(int,input().split()))
if m in a:
b=len(a) - a[::-1].index(m) - 1
print(b+1)
else:
print(-1)
#Keep visiting for more solutions of HackerEarth problems in Python 3.Thank you!!!