x, y = gets.chomp.split(" ").map(&:to_i)
mod = 10 ** 9 + 7
N = 10 ** 6
n = (2 * y - x) / 3
m = (2 * x - y) / 3

$fact = [1, 1]
$factinv = [1, 1]
$inv = [0, 1]

def com(n, k, mod)
    return 0 if (k < 0) || (n < k)
    k = k > n-k ? n-k : k
    return $fact[n] * $factinv[k] * $factinv[n-k] % mod
end

(2..N).each do |i|
    $fact << ($fact[-1] * i) % mod
    $inv << (-$inv[mod % i] * (mod / i)) % mod
    $factinv << ($factinv[-1] * $inv[-1]) % mod
end

if n > 0 && m > 0 && (x+y) % 3 == 0 then
    puts com(n+m, n, mod)
else
    puts 0
end