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

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

def comInit(mod)
    max = 10 ** 6
    (2..max).each do |i|
        $fact << $fact[i-1] * i % mod
        $inv << mod - $inv[mod % i] * (mod / i) % mod
        $factinv << $factinv[i-1] * $inv[i] % mod
    end
end

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

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