n, m = map(int, input().split()) _ = [input() for i in range(n - 1)] print(m - 1 if m <= n else -1)