import math



P = 10**9 + 7

X, Y = list(map(int, input().split()))

if (X + Y) % 3 > 0:

    print((0))

    exit()

n = (X + Y) // 3

x = X - n

y = Y - n

if 0 > x or 0 > y:

    print((0))

    exit()

fact = [0] * (x + y + 1)

inv = [0] * (x + y + 1)

fact_inv = [0] * (x + y + 1)

fact[0], fact[1] = 1, 1

inv[0], inv[1] = 0, 1

fact_inv[0], fact_inv[1] = 1, 1

for i in range(2, x + y + 1):

    fact[i] = (fact[i - 1] * i) % P

    inv[i] = (-inv[P % i] * (P // i)) % P

    fact_inv[i] = (fact_inv[i - 1] * inv[i]) % P

print(((fact[x + y] * fact_inv[x] * fact_inv[y]) % P))

P = 10**9 + 7

X, Y = list(map(int, input().split()))

if (X + Y) % 3 > 0:

    print((0))

    exit()

n = (X + Y) // 3

x = X - n

y = Y - n

if 0 > x or 0 > y:

    print((0))

    exit()

fact = [0] * (x + y + 1)

inv = [0] * (x + y + 1)

fact_inv = [0] * (x + y + 1)

fact[0], fact[1] = 1, 1

inv[0], inv[1] = 0, 1

fact_inv[0], fact_inv[1] = 1, 1

for i in range(2, x + y + 1):

    fact[i] = (fact[i - 1] * i) % P

print(((fact[x + y] * pow(fact[x], P - 2, P) * pow(fact[y], P - 2, P)) % P))

import math

P = 10**9 + 7
X, Y = list(map(int, input().split()))
if (X + Y) % 3 > 0:
    print((0))
    exit()
n = (X + Y) // 3
x = X - n
y = Y - n
if 0 > x or 0 > y:
    print((0))
    exit()
fact = [0] * (x + y + 1)
inv = [0] * (x + y + 1)
fact_inv = [0] * (x + y + 1)
fact[0], fact[1] = 1, 1
inv[0], inv[1] = 0, 1
fact_inv[0], fact_inv[1] = 1, 1
for i in range(2, x + y + 1):
    fact[i] = (fact[i - 1] * i) % P
    inv[i] = (-inv[P % i] * (P // i)) % P
    fact_inv[i] = (fact_inv[i - 1] * inv[i]) % P
print(((fact[x + y] * fact_inv[x] * fact_inv[y]) % P))

P = 10**9 + 7
X, Y = list(map(int, input().split()))
if (X + Y) % 3 > 0:
    print((0))
    exit()
n = (X + Y) // 3
x = X - n
y = Y - n
if 0 > x or 0 > y:
    print((0))
    exit()
fact = [0] * (x + y + 1)
inv = [0] * (x + y + 1)
fact_inv = [0] * (x + y + 1)
fact[0], fact[1] = 1, 1
inv[0], inv[1] = 0, 1
fact_inv[0], fact_inv[1] = 1, 1
for i in range(2, x + y + 1):
    fact[i] = (fact[i - 1] * i) % P
print(((fact[x + y] * pow(fact[x], P - 2, P) * pow(fact[y], P - 2, P)) % P))

-import math - -    inv[i] = (-inv[P % i] * (P // i)) % P -    fact_inv[i] = (fact_inv[i - 1] * inv[i]) % P -print(((fact[x + y] * fact_inv[x] * fact_inv[y]) % P)) +print(((fact[x + y] * pow(fact[x], P - 2, P) * pow(fact[y], P - 2, P)) % P))