n, m = map(int, input().split()) if n % m == 0 or n // m == 1: if n // m == 1: print(1) elif n // m == 2: print(2) else: print(-1) else: print(-1)