n, m=gets.split.map(&:to_i)

if n<=m
  puts 1
else
  if n<=2*m and n%2==0
    puts 2
  else
    puts (-1)
  end
end