# frozen_string_literal: true

x, y = gets.split.map(&:to_i)

if (2 * x - y) % 3 != 0 || (-x + 2 * y) % 3 != 0
  puts 0
  exit
end

n = (2 * x - y) / 3
m = (-x + 2 * y) / 3

MOD = 10**9 + 7
N = n * 3

def ncrmod(n, r)
  return 0 if r < 0 || r > n

  r = [r, n - r].min
  $g1[n] * $g2[r] * $g2[n - r] % MOD
end

$g1 = [1, 1]
$g2 = [1, 1]
$inverse = [0, 1]

2.upto(N + 1) do |i|
  $g1.push(($g1[-1] * i) % MOD)
  $inverse.push((-$inverse[MOD % i] * (MOD / i)) % MOD)
  $g2.push(($g2[-1] * $inverse[-1]) % MOD)
end

puts ncrmod(n + m, m)
