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



MOD = int(1.0e+9 + 7)

DP_max = 3333334



DP = []



X = int((2 * y - x) / 3)

Y = int((2 * x - y) / 3)



def cmb(n, r, p):

    if (r < 0) or (n < r):

        return 0

    r = min(r, n - r)

    return fact[n] * factinv[r] * factinv[n-r] % p



p = 10 ** 9 + 7

N = 10 ** 6  # N は必要分だけ用意する

fact = [1, 1]  # fact[n] = (n! mod p)

factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)

inv = [0, 1]  # factinv 計算用



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

    fact.append((fact[-1] * i) % p)

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

    factinv.append((factinv[-1] * inv[-1]) % p)



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

   (2 * y - x) < 0 or (2 * x - y) < 0):

    print((0))

else:

    print((cmb(X + Y, Y, MOD)))
x, y = list(map(int, input().split()))



def cmb(n, r, mod):

    if (r < 0) or (n < r):

        return 0

    r = min(r, n - r)

    return fact[n] * factinv[r] * factinv[n-r] % mod



X = int((2 * y - x) / 3)

Y = int((2 * x - y) / 3)



MOD = int(1.0e+9 + 7)

N = int(7.0e+5) # N は必要分だけ用意する

fact = [1, 1]  # fact[n] = (n! mod p)

factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)

inv = [0, 1]  # factinv 計算用



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

    fact.append((fact[-1] * i) % MOD)

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

    factinv.append((factinv[-1] * inv[-1]) % MOD)



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

   (2 * y - x) < 0 or (2 * x - y) < 0):

    print((0))

else:

    print((cmb(X + Y, Y, MOD)))
x, y = list(map(int, input().split()))
MOD = int(1.0e9 + 7)
DP_max = 3333334
DP = []
X = int((2 * y - x) / 3)
Y = int((2 * x - y) / 3)


def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p


p = 10**9 + 7
N = 10**6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
if (2 * y - x) % 3 != 0 or (2 * x - y) % 3 != 0 or (2 * y - x) < 0 or (2 * x - y) < 0:
    print((0))
else:
    print((cmb(X + Y, Y, MOD)))

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


def cmb(n, r, mod):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % mod


X = int((2 * y - x) / 3)
Y = int((2 * x - y) / 3)
MOD = int(1.0e9 + 7)
N = int(7.0e5)  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
    factinv.append((factinv[-1] * inv[-1]) % MOD)
if (2 * y - x) % 3 != 0 or (2 * x - y) % 3 != 0 or (2 * y - x) < 0 or (2 * x - y) < 0:
    print((0))
else:
    print((cmb(X + Y, Y, MOD)))

-MOD = int(1.0e9 + 7) -DP_max = 3333334 -DP = [] -X = int((2 * y - x) / 3) -Y = int((2 * x - y) / 3) -def cmb(n, r, p): +def cmb(n, r, mod): -    return fact[n] * factinv[r] * factinv[n - r] % p +    return fact[n] * factinv[r] * factinv[n - r] % mod -p = 10**9 + 7 -N = 10**6  # N は必要分だけ用意する +X = int((2 * y - x) / 3) +Y = int((2 * x - y) / 3) +MOD = int(1.0e9 + 7) +N = int(7.0e5)  # N は必要分だけ用意する -    fact.append((fact[-1] * i) % p) -    inv.append((-inv[p % i] * (p // i)) % p) -    factinv.append((factinv[-1] * inv[-1]) % p) +    fact.append((fact[-1] * i) % MOD) +    inv.append((-inv[MOD % i] * (MOD // i)) % MOD) +    factinv.append((factinv[-1] * inv[-1]) % MOD)