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

def cmb(n, r, p):

    if (r < 0) or (n < r):

        return 0

    r = min(r, n - r)

    return fact[n] * factinv[r] * factinv[n-r] % p



p = 10 ** 9 + 7

N = 10 ** 6

fact = [1, 1]

factinv = [1, 1]

inv = [0, 1]

 

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

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

    inv.append((-inv[p % i] * (p // i)) % p)

    factinv.append((factinv[-1] * inv[-1]) % p)



if (X+Y)%3:

    ans=0

else:

    N=(X+Y)//3

    if N<=X<=2*N and N<=Y<=2*N:

        ans=cmb(N,X-N,p)

    else:

        ans=0



print(ans)
def com(n,r,m):

 f=[1,1]

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

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

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

 

mod=10**9+7

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

z=(x+y)//3

if (x+y)%3 or abs(x-y)>z:

 ans=0

else:

    ans=com(z,x-z,mod)

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


def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p


p = 10**9 + 7
N = 10**6
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
if (X + Y) % 3:
    ans = 0
else:
    N = (X + Y) // 3
    if N <= X <= 2 * N and N <= Y <= 2 * N:
        ans = cmb(N, X - N, p)
    else:
        ans = 0
print(ans)

def com(n, r, m):
    f = [1, 1]
    for i in range(2, n + 1):
        f.append(f[i - 1] * i % m)
    return f[n] * pow(f[r] * f[n - r] % m, m - 2, m) % m


mod = 10**9 + 7
x, y = list(map(int, input().split()))
z = (x + y) // 3
if (x + y) % 3 or abs(x - y) > z:
    ans = 0
else:
    ans = com(z, x - z, mod)
print(ans)

-X, Y = list(map(int, input().split())) +def com(n, r, m): +    f = [1, 1] +    for i in range(2, n + 1): +        f.append(f[i - 1] * i % m) +    return f[n] * pow(f[r] * f[n - r] % m, m - 2, m) % m -def cmb(n, r, p): -    if (r < 0) or (n < r): -        return 0 -    r = min(r, n - r) -    return fact[n] * factinv[r] * factinv[n - r] % p - - -p = 10**9 + 7 -N = 10**6 -fact = [1, 1] -factinv = [1, 1] -inv = [0, 1] -for i in range(2, N + 1): -    fact.append((fact[-1] * i) % p) -    inv.append((-inv[p % i] * (p // i)) % p) -    factinv.append((factinv[-1] * inv[-1]) % p) -if (X + Y) % 3: +mod = 10**9 + 7 +x, y = list(map(int, input().split())) +z = (x + y) // 3 +if (x + y) % 3 or abs(x - y) > z: -    N = (X + Y) // 3 -    if N <= X <= 2 * N and N <= Y <= 2 * N: -        ans = cmb(N, X - N, p) -    else: -        ans = 0 +    ans = com(z, x - z, mod)