x, y = gets.split.map(&:to_i)
mod = 10**9 + 7

def factorial(x, mod)
  return 1 if x == 0
  1.upto(x).inject { |i, j| i * j % mod }
end

def inv_fact(x, mod)
  factorial(x, mod).pow(mod - 2, mod)
end

def combination(x, y, mod)
  factorial(x, mod) * inv_fact(y, mod) * inv_fact(x - y, mod)
end

if (2 * x - y) % 3 == 0 && (-x + 2 * y) % 3 == 0
  u = (2 * x - y) / 3
  v = (-x + 2 * y) / 3

  puts combination(u + v, u, mod) % mod
else
  puts 0
end