M=10**9+7

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

ans=0

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

  a=(2*y-x)//3

  b=(2*x-y)//3

  if a>=0 and b>=0:

    f1,f2=1,1

    for i in range(a+1,a+b+1):

      f1*=i

      f1%=M

    for i in range(1,b+1):

      f2*=i

      f2%=M

    ans=f1*pow(f2,M-2,M)



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

if 2*Y<X or 2*X<Y:

  print((0))

  exit()

if not((X%3==0 and Y%3==0) or (X%3==1 and Y%3==2) or (X%3==2 and Y%3==1)):

  print((0))

  exit()

P=10**9+7

A=(2*Y-X)//3

B=(2*X-Y)//3

num = 1

for i in range(A+1, A+B+1):

  num=num*i%P

den = 1

for j in range(1, B+1):

  den = den*j%P

den = pow(den,P-2,P)

print(((num*den)%P))
M = 10**9 + 7
x, y = list(map(int, input().split()))
ans = 0
if (x + y) % 3 == 0:
    a = (2 * y - x) // 3
    b = (2 * x - y) // 3
    if a >= 0 and b >= 0:
        f1, f2 = 1, 1
        for i in range(a + 1, a + b + 1):
            f1 *= i
            f1 %= M
        for i in range(1, b + 1):
            f2 *= i
            f2 %= M
        ans = f1 * pow(f2, M - 2, M)
print((ans % M))

X, Y = list(map(int, input().split()))
if 2 * Y < X or 2 * X < Y:
    print((0))
    exit()
if not (
    (X % 3 == 0 and Y % 3 == 0)
    or (X % 3 == 1 and Y % 3 == 2)
    or (X % 3 == 2 and Y % 3 == 1)
):
    print((0))
    exit()
P = 10**9 + 7
A = (2 * Y - X) // 3
B = (2 * X - Y) // 3
num = 1
for i in range(A + 1, A + B + 1):
    num = num * i % P
den = 1
for j in range(1, B + 1):
    den = den * j % P
den = pow(den, P - 2, P)
print(((num * den) % P))

-M = 10**9 + 7 -x, y = list(map(int, input().split())) -ans = 0 -if (x + y) % 3 == 0: -    a = (2 * y - x) // 3 -    b = (2 * x - y) // 3 -    if a >= 0 and b >= 0: -        f1, f2 = 1, 1 -        for i in range(a + 1, a + b + 1): -            f1 *= i -            f1 %= M -        for i in range(1, b + 1): -            f2 *= i -            f2 %= M -        ans = f1 * pow(f2, M - 2, M) -print((ans % M)) +X, Y = list(map(int, input().split())) +if 2 * Y < X or 2 * X < Y: +    print((0)) +    exit() +if not ( +    (X % 3 == 0 and Y % 3 == 0) +    or (X % 3 == 1 and Y % 3 == 2) +    or (X % 3 == 2 and Y % 3 == 1) +): +    print((0)) +    exit() +P = 10**9 + 7 +A = (2 * Y - X) // 3 +B = (2 * X - Y) // 3 +num = 1 +for i in range(A + 1, A + B + 1): +    num = num * i % P +den = 1 +for j in range(1, B + 1): +    den = den * j % P +den = pow(den, P - 2, P) +print(((num * den) % P))