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

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

$fac = Array.new(n+1)
$finv = Array.new(n+1)
$inv = Array.new(n+1)

def comInit(n, mod)
    $fac[0] = $fac[1] = 1
    $finv[0] = $finv[1] = 1
    $inv[1] = 1
    (2..n).each do |i|
        $fac[i] = $fac[i - 1] * i % mod
        $inv[i] = mod - $inv[mod % i] * (mod / i) % mod
        $finv[i] = $finv[i - 1] * $inv[i] % mod
    end
end

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

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