x,y = list(map(int,input().split()))

ans = 0

mod = 10**9+7



if (x+y)%3 == 0:

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

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

    if m >= 0 and n >= 0:

        fac = [1]*(m+n+1)

        for i in range(2,m+n+1): 

            fac[i] = fac[i-1]*i % mod

        ans = fac[m+n]*(pow(fac[m],mod-2,mod)*pow(fac[n],mod-2,mod)%mod)%mod



print(ans)
def comb(n,k,mod):

    x = y = 1

    for i in range(min(k,n-k)):

        x = x*(n-i)%mod

        y = y*(i+1)%mod

    return x * pow(y, mod-2, mod) % mod



x,y = list(map(int,input().split()))

ans = 0

mod = 10**9+7

if (x+y)%3 == 0:

    a = (-x+2*y)//3

    b = (2*x-y)//3

    if a >= 0 and b >= 0: ans = comb(a+b,a,mod)

print(ans)
x, y = list(map(int, input().split()))
ans = 0
mod = 10**9 + 7
if (x + y) % 3 == 0:
    m = (2 * y - x) // 3
    n = (2 * x - y) // 3
    if m >= 0 and n >= 0:
        fac = [1] * (m + n + 1)
        for i in range(2, m + n + 1):
            fac[i] = fac[i - 1] * i % mod
        ans = (
            fac[m + n]
            * (pow(fac[m], mod - 2, mod) * pow(fac[n], mod - 2, mod) % mod)
            % mod
        )
print(ans)

def comb(n, k, mod):
    x = y = 1
    for i in range(min(k, n - k)):
        x = x * (n - i) % mod
        y = y * (i + 1) % mod
    return x * pow(y, mod - 2, mod) % mod


x, y = list(map(int, input().split()))
ans = 0
mod = 10**9 + 7
if (x + y) % 3 == 0:
    a = (-x + 2 * y) // 3
    b = (2 * x - y) // 3
    if a >= 0 and b >= 0:
        ans = comb(a + b, a, mod)
print(ans)

+def comb(n, k, mod): +    x = y = 1 +    for i in range(min(k, n - k)): +        x = x * (n - i) % mod +        y = y * (i + 1) % mod +    return x * pow(y, mod - 2, mod) % mod + + -    m = (2 * y - x) // 3 -    n = (2 * x - y) // 3 -    if m >= 0 and n >= 0: -        fac = [1] * (m + n + 1) -        for i in range(2, m + n + 1): -            fac[i] = fac[i - 1] * i % mod -        ans = ( -            fac[m + n] -            * (pow(fac[m], mod - 2, mod) * pow(fac[n], mod - 2, mod) % mod) -            % mod -        ) +    a = (-x + 2 * y) // 3 +    b = (2 * x - y) // 3 +    if a >= 0 and b >= 0: +        ans = comb(a + b, a, mod)