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

output = 0



Z = X+Y



def modinv(a, mod=10**9+7):

    return pow(a, mod-2, mod)



def combination(n, r, mod=10**9+7):

    r = min(r, n-r)

    res = 1

    for i in range(r):

        res = res * (n - i) * modinv(i+1, mod) % mod

    return res



if (Z%3==0)and(Z/3<=X)and(Z/3<=Y):

    T = int(Z/3)

    S = abs(int(Z/3)-min(X,Y))

    output = combination(T,S, mod=10**9+7)



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



MAXN = 2*(10**6)+10

p = 10**9+7

f = [1]

for i in range(MAXN):

    f.append(f[-1] * (i+1) % p)

def nCr(n, r, mod=p):

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





Z = (X+Y)//3

if Z*3!=X+Y:

    print((0))

else:

    P,Q = X-Z, Y-Z

    if P<0 or Q<0:

        print((0))

    else:

        print((nCr(Z,P)))

[X, Y] = list(map(int, input().split()))
output = 0
Z = X + Y


def modinv(a, mod=10**9 + 7):
    return pow(a, mod - 2, mod)


def combination(n, r, mod=10**9 + 7):
    r = min(r, n - r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i + 1, mod) % mod
    return res


if (Z % 3 == 0) and (Z / 3 <= X) and (Z / 3 <= Y):
    T = int(Z / 3)
    S = abs(int(Z / 3) - min(X, Y))
    output = combination(T, S, mod=10**9 + 7)
print(output)

X, Y = list(map(int, input().split()))
MAXN = 2 * (10**6) + 10
p = 10**9 + 7
f = [1]
for i in range(MAXN):
    f.append(f[-1] * (i + 1) % p)


def nCr(n, r, mod=p):
    return f[n] * pow(f[r], mod - 2, mod) * pow(f[n - r], mod - 2, mod) % mod


Z = (X + Y) // 3
if Z * 3 != X + Y:
    print((0))
else:
    P, Q = X - Z, Y - Z
    if P < 0 or Q < 0:
        print((0))
    else:
        print((nCr(Z, P)))

-[X, Y] = list(map(int, input().split())) -output = 0 -Z = X + Y +X, Y = list(map(int, input().split())) +MAXN = 2 * (10**6) + 10 +p = 10**9 + 7 +f = [1] +for i in range(MAXN): +    f.append(f[-1] * (i + 1) % p) -def modinv(a, mod=10**9 + 7): -    return pow(a, mod - 2, mod) +def nCr(n, r, mod=p): +    return f[n] * pow(f[r], mod - 2, mod) * pow(f[n - r], mod - 2, mod) % mod -def combination(n, r, mod=10**9 + 7): -    r = min(r, n - r) -    res = 1 -    for i in range(r): -        res = res * (n - i) * modinv(i + 1, mod) % mod -    return res - - -if (Z % 3 == 0) and (Z / 3 <= X) and (Z / 3 <= Y): -    T = int(Z / 3) -    S = abs(int(Z / 3) - min(X, Y)) -    output = combination(T, S, mod=10**9 + 7) -print(output) +Z = (X + Y) // 3 +if Z * 3 != X + Y: +    print((0)) +else: +    P, Q = X - Z, Y - Z +    if P < 0 or Q < 0: +        print((0)) +    else: +        print((nCr(Z, P)))