X,Y=gets.split.map(&:to_i)
MOD=10**9+7

def pow(a,b,mod)
    res = 1
    while 0 < b
        res = res * a % mod if b & 1 == 1
        a = a * a % mod
        b >>= 1
    end
    res
end

def inv(a,mod)
    pow(a,mod-2,mod)
end

def comb(a,b,mod)
    x = (a-b+1..a).inject(1) {|n,x| n*x%mod }
    y = (1..b).inject(1) {|n,x| n*x%mod }
    x * inv(y,mod) % mod
end

if (X+Y)%3 != 0 || X*2 < Y || X > Y*2
    puts 0
    exit
end

y = (X*2 - Y) / 3
x = X - y
# xCy

# p [x,y]
p comb(x,y,MOD)