num=map(int, raw_input().split()) if num[1]>=num[0]: print 1 elif num[0]%2==0 and num[0]/2<=num[1]: print 2 else: print -1