N, K = map(int,input().split()) print(K - 1 if N >= K else -1)