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