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

mod=10**9+7

if (X+Y)%3!=0:

    print((0));exit()

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

    print((0));exit()

t=(X+Y)//3

f=[1]

for i in range(1,t+100):

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

def comb(a,b,m):

    return f[a]*pow(f[b],m-2,m)*pow(f[a-b],m-2,m)%m

print((comb(t,X-t,mod)))

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()))
mod = 10**9 + 7
if (X + Y) % 3 != 0:
    print((0))
    exit()
if X * 2 < Y or Y * 2 < X:
    print((0))
    exit()
t = (X + Y) // 3
f = [1]
for i in range(1, t + 100):
    f.append(f[-1] * i % mod)


def comb(a, b, m):
    return f[a] * pow(f[b], m - 2, m) * pow(f[a - b], m - 2, m) % m


print((comb(t, X - t, mod)))

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())) -mod = 10**9 + 7 -if (X + Y) % 3 != 0: -    print((0)) -    exit() -if X * 2 < Y or Y * 2 < X: -    print((0)) -    exit() -t = (X + Y) // 3 -f = [1] -for i in range(1, t + 100): -    f.append(f[-1] * i % mod) - - -def comb(a, b, m): -    return f[a] * pow(f[b], m - 2, m) * pow(f[a - b], m - 2, m) % m - - -print((comb(t, X - t, mod))) +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))