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

a3=2*x-y

b3=2*y-x

MOD=10**9+7



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



if a3%3!=0 or b3%3!=0:

  print((0))

else:

  a=a3//3

  b=b3//3

  if a>b:

    a,b=b,a

  

  N=a+b



  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 )



  ans = cmb(N,a,MOD)

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



# (i+1,j+2)の移動をa回

# (i+2,j+1)の移動をb回

# X=a+2b

# Y=2a+b

# となるa,bが存在するか？

# b=(2X-Y)/3が整数となればOK



b=(2*X-Y)/3

if not float.is_integer(b):

  print((0))

  exit(0)

  

b=int(b)

a=X-2*b



# aとbの回数が決まったので、a+bCmin(a,b)をやればいい



DIV=10**9+7

from functools import reduce

def nCr(n,r,DIV):

  if r<n-r:

    r=n-r

  if r==0:

    return 1

  f=lambda x,y:x*y%DIV

  X=reduce(f,list(range(n-r+1,n+1)))

  Y=reduce(f,list(range(1,r+1)))

  return X*pow(Y,DIV-2,DIV)%DIV



print((nCr(a+b,b,DIV)))
x, y = list(map(int, input().split()))
a3 = 2 * x - y
b3 = 2 * y - x
MOD = 10**9 + 7


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


if a3 % 3 != 0 or b3 % 3 != 0:
    print((0))
else:
    a = a3 // 3
    b = b3 // 3
    if a > b:
        a, b = b, a
    N = a + b
    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)
    ans = cmb(N, a, MOD)
    print((ans % MOD))

X, Y = list(map(int, input().split()))
# (i+1,j+2)の移動をa回
# (i+2,j+1)の移動をb回
# X=a+2b
# Y=2a+b
# となるa,bが存在するか？
# b=(2X-Y)/3が整数となればOK
b = (2 * X - Y) / 3
if not float.is_integer(b):
    print((0))
    exit(0)
b = int(b)
a = X - 2 * b
# aとbの回数が決まったので、a+bCmin(a,b)をやればいい
DIV = 10**9 + 7
from functools import reduce


def nCr(n, r, DIV):
    if r < n - r:
        r = n - r
    if r == 0:
        return 1
    f = lambda x, y: x * y % DIV
    X = reduce(f, list(range(n - r + 1, n + 1)))
    Y = reduce(f, list(range(1, r + 1)))
    return X * pow(Y, DIV - 2, DIV) % DIV


print((nCr(a + b, b, DIV)))

-x, y = list(map(int, input().split())) -a3 = 2 * x - y -b3 = 2 * y - x -MOD = 10**9 + 7 +X, Y = list(map(int, input().split())) +# (i+1,j+2)の移動をa回 +# (i+2,j+1)の移動をb回 +# X=a+2b +# Y=2a+b +# となるa,bが存在するか？ +# b=(2X-Y)/3が整数となればOK +b = (2 * X - Y) / 3 +if not float.is_integer(b): +    print((0)) +    exit(0) +b = int(b) +a = X - 2 * b +# aとbの回数が決まったので、a+bCmin(a,b)をやればいい +DIV = 10**9 + 7 +from functools import reduce -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 +def nCr(n, r, DIV): +    if r < n - r: +        r = n - r +    if r == 0: +        return 1 +    f = lambda x, y: x * y % DIV +    X = reduce(f, list(range(n - r + 1, n + 1))) +    Y = reduce(f, list(range(1, r + 1))) +    return X * pow(Y, DIV - 2, DIV) % DIV -if a3 % 3 != 0 or b3 % 3 != 0: -    print((0)) -else: -    a = a3 // 3 -    b = b3 // 3 -    if a > b: -        a, b = b, a -    N = a + b -    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) -    ans = cmb(N, a, MOD) -    print((ans % MOD)) +print((nCr(a + b, b, DIV)))