N,K = [int(i) for i in input().split()] if N < K: print(-1) else: print(K-1)