# -*- coding: utf-8 -*- """ No.531 エヌスクミ島の平和協定 https://yukicoder.me/problems/no/531 """ import sys from sys import stdin input = stdin.readline def main(args): n, m = map(int, input().split()) if n <= m: print(1) elif n % 2 == 1: print(-1) elif n <= m*2: print(2) else: print(-1) if __name__ == '__main__': main(sys.argv[1:])