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

if x > y*2 or y > x*2 or (x+y)%3 != 0:

  print((0))

  exit()

n = (x+y)//3

r = min(x-n,2*n-x)



def cmb(n, r, mod):

    if ( r<0 or r>n ):

        return 0

    r = min(r, n-r)

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



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 )



print((cmb(n,r,mod)))
x,y = list(map(int,input().split()))

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

    print((0))

    quit()

elif x < (x+y)//3 or y < (x+y)//3:

    print((0))

    quit()

else:

    n = (x+y)//3

    r = x-n



mod = 10**9+7

def cmb(n,r,mod):

    r = min(r, n-r)

    return (fact[n] * factinv[r] * factinv[n-r]) % mod

def makefact(n,mod):

    fact = [1,1]

    factinv = [1,1]

    inv = [0,1]

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

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

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

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

    return fact,factinv

fact,factinv = makefact(n,mod)



print((cmb(n,r,mod)))
x, y = list(map(int, input().split()))
if x > y * 2 or y > x * 2 or (x + y) % 3 != 0:
    print((0))
    exit()
n = (x + y) // 3
r = min(x - n, 2 * n - x)


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


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)
print((cmb(n, r, mod)))

x, y = list(map(int, input().split()))
if (x + y) % 3 != 0:
    print((0))
    quit()
elif x < (x + y) // 3 or y < (x + y) // 3:
    print((0))
    quit()
else:
    n = (x + y) // 3
    r = x - n
mod = 10**9 + 7


def cmb(n, r, mod):
    r = min(r, n - r)
    return (fact[n] * factinv[r] * factinv[n - r]) % mod


def makefact(n, mod):
    fact = [1, 1]
    factinv = [1, 1]
    inv = [0, 1]
    for i in range(2, n + 1):
        fact.append((fact[-1] * i) % mod)
        inv.append(-inv[mod % i] * (mod // i) % mod)
        factinv.append((factinv[-1] * inv[-1]) % mod)
    return fact, factinv


fact, factinv = makefact(n, mod)
print((cmb(n, r, mod)))

-if x > y * 2 or y > x * 2 or (x + y) % 3 != 0: +if (x + y) % 3 != 0: -    exit() -n = (x + y) // 3 -r = min(x - n, 2 * n - x) +    quit() +elif x < (x + y) // 3 or y < (x + y) // 3: +    print((0)) +    quit() +else: +    n = (x + y) // 3 +    r = x - n +mod = 10**9 + 7 -    if r < 0 or r > n: -        return 0 -    return g1[n] * g2[r] * g2[n - r] % mod +    return (fact[n] * factinv[r] * factinv[n - r]) % mod -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 makefact(n, mod): +    fact = [1, 1] +    factinv = [1, 1] +    inv = [0, 1] +    for i in range(2, n + 1): +        fact.append((fact[-1] * i) % mod) +        inv.append(-inv[mod % i] * (mod // i) % mod) +        factinv.append((factinv[-1] * inv[-1]) % mod) +    return fact, factinv + + +fact, factinv = makefact(n, mod)