x,y=map(int,input().split());print(x-1 if x>=y else -1)