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))

def fact(n, k, mod):

    res = 1

    for i in range(k):

        res = res * (n - i) % mod

    return res



def c(x, y, mod):

    y = min(x, x - y)

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



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()

print((c(x + y, x, 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))

def fact(n, k, mod):
    res = 1
    for i in range(k):
        res = res * (n - i) % mod
    return res


def c(x, y, mod):
    y = min(x, x - y)
    return (fact(x, y, mod) * pow(fact(y, y, mod), mod - 2, mod)) % mod


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()
print((c(x + y, x, P)))

+def fact(n, k, mod): +    res = 1 +    for i in range(k): +        res = res * (n - i) % mod +    return res + + +def c(x, y, mod): +    y = min(x, x - y) +    return (fact(x, y, mod) * pow(fact(y, y, mod), mod - 2, mod)) % mod + + -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)) +print((c(x + y, x, P)))