def comb(n, k, MOD):

    if n < k or n < 0 or k < 0:

        return 0

    k = min(k, n - k)

    if k == 0:

        return 1

    iinv = [1] * (k + 1)

    ans = n

    for i in range(2, k + 1):

        iinv[i] = MOD - iinv[MOD % i] * (MOD // i) % MOD

        ans *= (n + 1 - i) * iinv[i] % MOD

        ans %= MOD

    return ans



mm = 10**9 + 7

x, y = (int(x) for x in input().split())

ans = 0

if (x - 2*y) % 3 == 0:

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

    alpha = y - 2*beta

    ans = comb(alpha+beta, beta, mm)

print(ans)
# https://www.geeksforgeeks.org/compute-ncr-p-set-3-using-fermat-little-theorem/

def comb(n, r, p): 

    num = den = 1 

    for i in range(r): 

        num = (num * (n - i)) % p 

        den = (den * (i + 1)) % p 

    return (num * pow(den,  p - 2, p)) % p 

  

m = 10**9 + 7

x, y = (int(x) for x in input().split())

ans = 0

if (x - 2*y) % 3 == 0:

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

    alpha = y - 2*beta

    ans = comb(alpha+beta, max(alpha, beta), m)

print(ans)
def comb(n, k, MOD):
    if n < k or n < 0 or k < 0:
        return 0
    k = min(k, n - k)
    if k == 0:
        return 1
    iinv = [1] * (k + 1)
    ans = n
    for i in range(2, k + 1):
        iinv[i] = MOD - iinv[MOD % i] * (MOD // i) % MOD
        ans *= (n + 1 - i) * iinv[i] % MOD
        ans %= MOD
    return ans


mm = 10**9 + 7
x, y = (int(x) for x in input().split())
ans = 0
if (x - 2 * y) % 3 == 0:
    beta = (x - 2 * y) // -3
    alpha = y - 2 * beta
    ans = comb(alpha + beta, beta, mm)
print(ans)

# https://www.geeksforgeeks.org/compute-ncr-p-set-3-using-fermat-little-theorem/
def comb(n, r, p):
    num = den = 1
    for i in range(r):
        num = (num * (n - i)) % p
        den = (den * (i + 1)) % p
    return (num * pow(den, p - 2, p)) % p


m = 10**9 + 7
x, y = (int(x) for x in input().split())
ans = 0
if (x - 2 * y) % 3 == 0:
    beta = (x - 2 * y) // -3
    alpha = y - 2 * beta
    ans = comb(alpha + beta, max(alpha, beta), m)
print(ans)

-def comb(n, k, MOD): -    if n < k or n < 0 or k < 0: -        return 0 -    k = min(k, n - k) -    if k == 0: -        return 1 -    iinv = [1] * (k + 1) -    ans = n -    for i in range(2, k + 1): -        iinv[i] = MOD - iinv[MOD % i] * (MOD // i) % MOD -        ans *= (n + 1 - i) * iinv[i] % MOD -        ans %= MOD -    return ans +# https://www.geeksforgeeks.org/compute-ncr-p-set-3-using-fermat-little-theorem/ +def comb(n, r, p): +    num = den = 1 +    for i in range(r): +        num = (num * (n - i)) % p +        den = (den * (i + 1)) % p +    return (num * pow(den, p - 2, p)) % p -mm = 10**9 + 7 +m = 10**9 + 7 -    ans = comb(alpha + beta, beta, mm) +    ans = comb(alpha + beta, max(alpha, beta), m)