def binomial_p(n, k, p):

    '''

    Input: integers n, k such that n >= k >= 0, prime number p

    Output: n choose k mod p

    '''



    k = min(k, n-k)

    fct_n = 1  # factorial of n mod p = 1 * 2 * ... * n mod p

    inv = [0, 1] # inv[i] : inverse of i mod p

    invfct_k = 1 # factorial of inverse of k mod p = 1^(-1) * 2^(-1) * ... * k^(-1) mod p

    invfct_n_k = 1  # factorial of inverse of (n-k) mod p



    # Calculate inverse, factorial, factorial of inverse of i

    # all at the same time

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

        fct_n = (fct_n * i) % p

        inv.append(( inv[p % i] * (p - p//i) ) % p )

        invfct_n_k = invfct_n_k * inv[-1] % p

        if i == k:

            invfct_k = invfct_n_k



    for i in range(n - k + 1, n + 1):

        fct_n = (fct_n * i) % p



    return ((fct_n * invfct_k % p) * invfct_n_k) % p







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



n, rn = divmod(2 * x - y, 3)

m, rm = divmod(2 * y - x, 3)

p = 10**9 + 7



if rn != 0 or rm != 0 or n < 0 or m < 0:

    ans = 0

else:

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

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

    ans = binomial_p(a + b, b, p)



print(ans)

# 20-7-30 再トライ

import sys



def binomial_p(n, k, p):

    k = min(k, n - k)

    if k == 0: return 1

    numer = 1

    denom = 1

    for i in range(k):

        numer = numer * (n - i) % p

        denom = denom * (k - i) % p

    return numer * pow(denom, p - 2, p) % p





X, Y = [int(x) for x in input().split()]

p = 10 ** 9 + 7



if (2 * X - Y) % 3 != 0 or (2 * Y - X) % 3 != 0 or\

    2 * X - Y < 0 or 2 * Y - X < 0:

    print(0)

    sys.exit()



m = (2 * X - Y) // 3

n = (2 * Y - X) // 3

print(binomial_p(m + n, m, p))

def binomial_p(n, k, p):
    """
    Input: integers n, k such that n >= k >= 0, prime number p
    Output: n choose k mod p
    """
    k = min(k, n - k)
    fct_n = 1  # factorial of n mod p = 1 * 2 * ... * n mod p
    inv = [0, 1]  # inv[i] : inverse of i mod p
    invfct_k = (
        1  # factorial of inverse of k mod p = 1^(-1) * 2^(-1) * ... * k^(-1) mod p
    )
    invfct_n_k = 1  # factorial of inverse of (n-k) mod p
    # Calculate inverse, factorial, factorial of inverse of i
    # all at the same time
    for i in range(2, n - k + 1):
        fct_n = (fct_n * i) % p
        inv.append((inv[p % i] * (p - p // i)) % p)
        invfct_n_k = invfct_n_k * inv[-1] % p
        if i == k:
            invfct_k = invfct_n_k
    for i in range(n - k + 1, n + 1):
        fct_n = (fct_n * i) % p
    return ((fct_n * invfct_k % p) * invfct_n_k) % p


x, y = [int(a) for a in input().split()]
n, rn = divmod(2 * x - y, 3)
m, rm = divmod(2 * y - x, 3)
p = 10**9 + 7
if rn != 0 or rm != 0 or n < 0 or m < 0:
    ans = 0
else:
    a = (2 * x - y) // 3
    b = (2 * y - x) // 3
    ans = binomial_p(a + b, b, p)
print(ans)

# 20-7-30 再トライ
import sys


def binomial_p(n, k, p):
    k = min(k, n - k)
    if k == 0:
        return 1
    numer = 1
    denom = 1
    for i in range(k):
        numer = numer * (n - i) % p
        denom = denom * (k - i) % p
    return numer * pow(denom, p - 2, p) % p


X, Y = [int(x) for x in input().split()]
p = 10**9 + 7
if (2 * X - Y) % 3 != 0 or (2 * Y - X) % 3 != 0 or 2 * X - Y < 0 or 2 * Y - X < 0:
    print(0)
    sys.exit()
m = (2 * X - Y) // 3
n = (2 * Y - X) // 3
print(binomial_p(m + n, m, p))

-def binomial_p(n, k, p): -    """ -    Input: integers n, k such that n >= k >= 0, prime number p -    Output: n choose k mod p -    """ -    k = min(k, n - k) -    fct_n = 1  # factorial of n mod p = 1 * 2 * ... * n mod p -    inv = [0, 1]  # inv[i] : inverse of i mod p -    invfct_k = ( -        1  # factorial of inverse of k mod p = 1^(-1) * 2^(-1) * ... * k^(-1) mod p -    ) -    invfct_n_k = 1  # factorial of inverse of (n-k) mod p -    # Calculate inverse, factorial, factorial of inverse of i -    # all at the same time -    for i in range(2, n - k + 1): -        fct_n = (fct_n * i) % p -        inv.append((inv[p % i] * (p - p // i)) % p) -        invfct_n_k = invfct_n_k * inv[-1] % p -        if i == k: -            invfct_k = invfct_n_k -    for i in range(n - k + 1, n + 1): -        fct_n = (fct_n * i) % p -    return ((fct_n * invfct_k % p) * invfct_n_k) % p +# 20-7-30 再トライ +import sys -x, y = [int(a) for a in input().split()] -n, rn = divmod(2 * x - y, 3) -m, rm = divmod(2 * y - x, 3) +def binomial_p(n, k, p): +    k = min(k, n - k) +    if k == 0: +        return 1 +    numer = 1 +    denom = 1 +    for i in range(k): +        numer = numer * (n - i) % p +        denom = denom * (k - i) % p +    return numer * pow(denom, p - 2, p) % p + + +X, Y = [int(x) for x in input().split()] -if rn != 0 or rm != 0 or n < 0 or m < 0: -    ans = 0 -else: -    a = (2 * x - y) // 3 -    b = (2 * y - x) // 3 -    ans = binomial_p(a + b, b, p) -print(ans) +if (2 * X - Y) % 3 != 0 or (2 * Y - X) % 3 != 0 or 2 * X - Y < 0 or 2 * Y - X < 0: +    print(0) +    sys.exit() +m = (2 * X - Y) // 3 +n = (2 * Y - X) // 3 +print(binomial_p(m + n, m, p))