# https://atcoder.jp/contests/abc145/tasks/abc145_d

def mod_pow(x, n, mod)
  ret = 1
  while n > 0
    ret = ret * x % mod if n & 1 > 0
    x = x * x % mod
    n >>= 1
  end
  ret
end

def mod_inverse(x, mod)
  mod_pow(x, mod - 2, mod)
end

def mod_fact(n, mod)
  (1..n).reduce(1) { |a, e| a * e % mod }
end

def mod_comb(n, k, mod)
  return 0 if n < 0 || k < 0 || n < k
  return 1 if k.zero? || k == n
  a = mod_fact(n, mod)
  b = mod_fact(k, mod) * mod_fact(n - k, mod) % mod
  a * mod_inverse(b, mod) % mod
end

MOD = 10**9+7

X, Y = gets.split.map(&:to_i)
x, y = [2 * X - Y, 2 * Y - X]
ans =
  if x < 0 || y < 0
    0
  elsif x % 3 > 0 || y % 3 > 0
    0
  else
    x, y = [x / 3, y / 3]
    mod_comb(x + y, x, MOD)
  end

puts ans
