n, m = gets.split.map(&:to_i) if m >= n puts 1 elsif m/2 >= n && n%2 == 0 puts 2; elsif puts -1 end