mod = 10**9+7

N = 10**6

g1 = [1, 1]

g2 = [1, 1]

inverse = [0, 1]



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

    g1.append((g1[-1] * i) % mod)

    inverse.append((-inverse[mod % i] * (mod//i)) % mod)

    g2.append((g2[-1] * inverse[-1]) % mod)





def cmb(n, r, mod):

    if (r < 0 or r > n):

        return 0

    return g1[n] * g2[r] * g2[n-r] % mod





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



if (X + Y) % 3 != 0:

    ans = 0

else:

    n = (X + Y) // 3

    r = min(X, Y) - n

    ans = cmb(n, r, mod)

print(ans)

mod = 10**9+7



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





def comb(n, r, mod):

    if r < 0 or n < r:

        return 0

    return fact[n]*pow(fact[r], mod-2, mod) * pow(fact[n-r], mod-2, mod) % mod





if (X + Y) % 3 != 0:

    ans = 0

else:

    n = (X + Y) // 3

    r = min(X, Y)-n

    # nCr

    fact = [1, 1]

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

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

    ans = comb(n, r, mod)



print(ans)

mod = 10**9 + 7
N = 10**6
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)


def cmb(n, r, mod):
    if r < 0 or r > n:
        return 0
    return g1[n] * g2[r] * g2[n - r] % mod


X, Y = list(map(int, input().split()))
if (X + Y) % 3 != 0:
    ans = 0
else:
    n = (X + Y) // 3
    r = min(X, Y) - n
    ans = cmb(n, r, mod)
print(ans)

mod = 10**9 + 7
X, Y = list(map(int, input().split()))


def comb(n, r, mod):
    if r < 0 or n < r:
        return 0
    return fact[n] * pow(fact[r], mod - 2, mod) * pow(fact[n - r], mod - 2, mod) % mod


if (X + Y) % 3 != 0:
    ans = 0
else:
    n = (X + Y) // 3
    r = min(X, Y) - n
    # nCr
    fact = [1, 1]
    for i in range(2, n + 1):
        fact.append(fact[-1] * i % mod)
    ans = comb(n, r, mod)
print(ans)

-N = 10**6 -g1 = [1, 1] -g2 = [1, 1] -inverse = [0, 1] -for i in range(2, N + 1): -    g1.append((g1[-1] * i) % mod) -    inverse.append((-inverse[mod % i] * (mod // i)) % mod) -    g2.append((g2[-1] * inverse[-1]) % mod) +X, Y = list(map(int, input().split())) -def cmb(n, r, mod): -    if r < 0 or r > n: +def comb(n, r, mod): +    if r < 0 or n < r: -    return g1[n] * g2[r] * g2[n - r] % mod +    return fact[n] * pow(fact[r], mod - 2, mod) * pow(fact[n - r], mod - 2, mod) % mod -X, Y = list(map(int, input().split())) -    ans = cmb(n, r, mod) +    # nCr +    fact = [1, 1] +    for i in range(2, n + 1): +        fact.append(fact[-1] * i % mod) +    ans = comb(n, r, mod)