X, Y = gets.chomp.split(" ").map(&:to_i)
ONE = '1'.freeze
MOD = (10**9) + 7

def inv(x)
    res = 1 
    beki = x
    (MOD - 2).to_s(2).reverse.chars do |digest|
      res = (beki * res) % MOD if digest == ONE
      beki = (beki * beki) % MOD
    end
    res
end

def fact(s, e)
    (s..e).reduce(1) { |r, i| (r * i) % MOD }
end

def nCk(n, k)
    (fact(k + 1, n) * inv(fact(1, n - k) % MOD)) % MOD
end

if (2 * Y - X) % 3 == 0 && (2 * X - Y) % 3 == 0 && 2 * Y >= X && 2 * X >= Y
    a = (2 * Y - X) / 3
    b = (2 * X - Y) / 3
    puts nCk(a + b, a)
else
    puts 0
end

    