n,m = map(int,input().split()) import sys if n == 2: print(-1) exit() if n == 3 and m <= 2: print(-1) exit() if n <= m: print(1) elif n <= 2 * m: print(2) else: print(-1)