# https://atcoder.jp/contests/abc145/tasks/abc145_d





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



if (2*Y- X) % 3 or (2*X- Y) % 3:

    print((0))

    exit()



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

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



if x < 0 or y < 0:

    print((0))

    exit()



n = x + y

r = x





mod = 10**9 + 7

f = 1

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

    f = f*i % mod

fac = f

f = pow(f, mod-2, mod)

facinv = [f]

for i in range(n, 0, -1):

    f = f*i % mod

    facinv.append(f)

facinv.append(1)



print((fac * facinv[r] * facinv[n - r] % mod))
from functools import reduce



def combination2(n, r, MOD=10**9+7):

    if not 0 <= r <= n: return 0

    r = min(r, n - r)

    numerator = reduce(lambda x, y: x * y % MOD, list(range(n, n - r, -1)), 1)

    denominator = reduce(lambda x, y: x * y % MOD, list(range(1, r + 1)), 1)

    return numerator * pow(denominator, MOD - 2, MOD) % MOD



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

if (2*X-Y)%3 or (2*Y-X)%3:

    print((0))

    exit()

x, y = (2*X-Y)//3, (2*Y-X)//3

print((combination2(x+y,x)))

# https://atcoder.jp/contests/abc145/tasks/abc145_d
X, Y = list(map(int, input().split()))
if (2 * Y - X) % 3 or (2 * X - Y) % 3:
    print((0))
    exit()
x = (2 * Y - X) // 3
y = (2 * X - Y) // 3
if x < 0 or y < 0:
    print((0))
    exit()
n = x + y
r = x
mod = 10**9 + 7
f = 1
for i in range(1, n + 1):
    f = f * i % mod
fac = f
f = pow(f, mod - 2, mod)
facinv = [f]
for i in range(n, 0, -1):
    f = f * i % mod
    facinv.append(f)
facinv.append(1)
print((fac * facinv[r] * facinv[n - r] % mod))

from functools import reduce


def combination2(n, r, MOD=10**9 + 7):
    if not 0 <= r <= n:
        return 0
    r = min(r, n - r)
    numerator = reduce(lambda x, y: x * y % MOD, list(range(n, n - r, -1)), 1)
    denominator = reduce(lambda x, y: x * y % MOD, list(range(1, r + 1)), 1)
    return numerator * pow(denominator, MOD - 2, MOD) % MOD


X, Y = list(map(int, input().split()))
if (2 * X - Y) % 3 or (2 * Y - X) % 3:
    print((0))
    exit()
x, y = (2 * X - Y) // 3, (2 * Y - X) // 3
print((combination2(x + y, x)))

-# https://atcoder.jp/contests/abc145/tasks/abc145_d +from functools import reduce + + +def combination2(n, r, MOD=10**9 + 7): +    if not 0 <= r <= n: +        return 0 +    r = min(r, n - r) +    numerator = reduce(lambda x, y: x * y % MOD, list(range(n, n - r, -1)), 1) +    denominator = reduce(lambda x, y: x * y % MOD, list(range(1, r + 1)), 1) +    return numerator * pow(denominator, MOD - 2, MOD) % MOD + + -if (2 * Y - X) % 3 or (2 * X - Y) % 3: +if (2 * X - Y) % 3 or (2 * Y - X) % 3: -x = (2 * Y - X) // 3 -y = (2 * X - Y) // 3 -if x < 0 or y < 0: -    print((0)) -    exit() -n = x + y -r = x -mod = 10**9 + 7 -f = 1 -for i in range(1, n + 1): -    f = f * i % mod -fac = f -f = pow(f, mod - 2, mod) -facinv = [f] -for i in range(n, 0, -1): -    f = f * i % mod -    facinv.append(f) -facinv.append(1) -print((fac * facinv[r] * facinv[n - r] % mod)) +x, y = (2 * X - Y) // 3, (2 * Y - X) // 3 +print((combination2(x + y, x)))