fac = [0] * 700000

finv = [0] * 700000

inv = [0] * 700000

mod = 1000000007



fac[0] = fac[1] = 1

finv[0] = finv[1] = 1

inv[1] = 1

for i in range(2, 700000):

    fac[i] = fac[i - 1] * i % mod

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

    finv[i] = finv[i - 1] * inv[i] % mod



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



if (x + y) % 3 == 0:

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

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

    if k >= 0 and l >= 0:

        print((fac[k + l] * (finv[k] * finv[l] % mod) % mod))

    else:

        print((0))

else:

    print((0))

mod = 10 ** 9 + 7

ans = 0



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



if (x + y) % 3 == 0:

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

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

    if k >= 0 and l >= 0:

        fac = [1] * (k + l + 1)

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

            fac[i] = fac[i - 1] * i % mod

        ans = fac[k + l] * (pow(fac[k], mod - 2, mod) * pow(fac[l], mod - 2, mod) % mod) % mod



print(ans)

fac = [0] * 700000
finv = [0] * 700000
inv = [0] * 700000
mod = 1000000007
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1
for i in range(2, 700000):
    fac[i] = fac[i - 1] * i % mod
    inv[i] = mod - inv[mod % i] * (mod // i) % mod
    finv[i] = finv[i - 1] * inv[i] % mod
x, y = list(map(int, input().split()))
if (x + y) % 3 == 0:
    k = (2 * x - y) // 3
    l = (2 * y - x) // 3
    if k >= 0 and l >= 0:
        print((fac[k + l] * (finv[k] * finv[l] % mod) % mod))
    else:
        print((0))
else:
    print((0))

mod = 10**9 + 7
ans = 0
x, y = list(map(int, input().split()))
if (x + y) % 3 == 0:
    k = (2 * x - y) // 3
    l = (2 * y - x) // 3
    if k >= 0 and l >= 0:
        fac = [1] * (k + l + 1)
        for i in range(2, k + l + 1):
            fac[i] = fac[i - 1] * i % mod
        ans = (
            fac[k + l]
            * (pow(fac[k], mod - 2, mod) * pow(fac[l], mod - 2, mod) % mod)
            % mod
        )
print(ans)

-fac = [0] * 700000 -finv = [0] * 700000 -inv = [0] * 700000 -mod = 1000000007 -fac[0] = fac[1] = 1 -finv[0] = finv[1] = 1 -inv[1] = 1 -for i in range(2, 700000): -    fac[i] = fac[i - 1] * i % mod -    inv[i] = mod - inv[mod % i] * (mod // i) % mod -    finv[i] = finv[i - 1] * inv[i] % mod +mod = 10**9 + 7 +ans = 0 -        print((fac[k + l] * (finv[k] * finv[l] % mod) % mod)) -    else: -        print((0)) -else: -    print((0)) +        fac = [1] * (k + l + 1) +        for i in range(2, k + l + 1): +            fac[i] = fac[i - 1] * i % mod +        ans = ( +            fac[k + l] +            * (pow(fac[k], mod - 2, mod) * pow(fac[l], mod - 2, mod) % mod) +            % mod +        ) +print(ans)