n, m = gets.split.map(&:to_i) if n <= m print 1 elsif n/2 <= m && n%2 == 0 print 2 else print -1 end