a, b = gets.split.map(&:to_i) if a > b a, b = b, a end if 3*a == b puts "#{2*a}" else puts "-1" end