def main(): N, M = map(int, input().split()) if N == 2 or N <= M: ans = 1 elif not N & 1: ans = N // 2 else: ans = -1 print(ans) main()