n,k = map(int,input().split()) if n < k: print(-1) else: print(k - 1)