input = gets.chomp.split(" ").map(&:to_i)
X = input[0]
Y = input[1]

answer = 0
if (2 * Y - X) % 3 == 0 && (2 * X - Y) % 3 == 0
  m = (2 * Y - X) / 3
  n = (2 * X - Y) / 3 
  answer = 1
  m.times do |i|
    answer = answer * (n + 1 + i) / (i + 1)
  end
end

puts answer % ((10 ** 9) + 7)