N,K=map(int,input().split()) P=[input() for _ in range(N-1)] print(K-1 if N>=K else -1)