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