n,k=map(int,input().split()) a=[input()for i in range(n-1)] print(k-1 if n>=k else -1)