require 'openssl'
X, Y = gets.split.map(&:to_i)

num_moves = (X+Y)/3

for i in 0..num_moves
    if [X, Y] == [i + 2 * (num_moves - i), (num_moves - i) + 2 * i]
        num_a = i
        break
    end
end

if !num_a || (X + Y) % 3 != 0
    p 0
    exit
end

if num_a == num_moves
    p 1
    exit
end

a = ((num_a + 1)..(num_moves)).inject{|prod, n| prod * n % (10**9+7)}
b = (1..(num_moves - num_a)).inject{|prod, n| prod * n % (10**9+7)}
p a * OpenSSL::BN.new(b).mod_inverse(10**9+7) % (10**9+7)