MOD=10**9+7

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

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

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

if 2*a+b!=x:

    print((0))

    exit()



factorial = [1]

inverse = [1]



n=a+b

r=a



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

    factorial.append(factorial[-1] * i % MOD)

    inverse.append(pow(factorial[-1], MOD - 2, MOD))



def combi(n, r):

    if n < r or r < 0:

        return 0

    elif r == 0:

        return 1

    return factorial[n] * inverse[r] * inverse[n - r] % MOD



ans = combi(n,r)

print(ans)

N=10**9+7

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

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

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



if 2*a+b!=x:

    print((0))

    exit()



n=a+b

r=a



def fac(n,r,N):

    ans=1

    for i in range(r):

        ans=ans*(n-i)%N

    return ans



def combi(n,r,N):

    if n<r or n<0 or r<0:

        ans = 0

        return ans

    r= min(r, n-r)

    ans = fac(n,r,N)*pow(fac(r,r,N),N-2,N)%N

    return ans



ans = combi(n,r,N)

print(ans)

MOD = 10**9 + 7
x, y = list(map(int, input().split()))
a = (2 * x - y) // 3
b = (2 * y - x) // 3
if 2 * a + b != x:
    print((0))
    exit()
factorial = [1]
inverse = [1]
n = a + b
r = a
for i in range(1, n + 2):
    factorial.append(factorial[-1] * i % MOD)
    inverse.append(pow(factorial[-1], MOD - 2, MOD))


def combi(n, r):
    if n < r or r < 0:
        return 0
    elif r == 0:
        return 1
    return factorial[n] * inverse[r] * inverse[n - r] % MOD


ans = combi(n, r)
print(ans)

N = 10**9 + 7
x, y = list(map(int, input().split()))
a = (2 * x - y) // 3
b = (2 * y - x) // 3
if 2 * a + b != x:
    print((0))
    exit()
n = a + b
r = a


def fac(n, r, N):
    ans = 1
    for i in range(r):
        ans = ans * (n - i) % N
    return ans


def combi(n, r, N):
    if n < r or n < 0 or r < 0:
        ans = 0
        return ans
    r = min(r, n - r)
    ans = fac(n, r, N) * pow(fac(r, r, N), N - 2, N) % N
    return ans


ans = combi(n, r, N)
print(ans)

-MOD = 10**9 + 7 +N = 10**9 + 7 -factorial = [1] -inverse = [1] -for i in range(1, n + 2): -    factorial.append(factorial[-1] * i % MOD) -    inverse.append(pow(factorial[-1], MOD - 2, MOD)) -def combi(n, r): -    if n < r or r < 0: -        return 0 -    elif r == 0: -        return 1 -    return factorial[n] * inverse[r] * inverse[n - r] % MOD +def fac(n, r, N): +    ans = 1 +    for i in range(r): +        ans = ans * (n - i) % N +    return ans -ans = combi(n, r) +def combi(n, r, N): +    if n < r or n < 0 or r < 0: +        ans = 0 +        return ans +    r = min(r, n - r) +    ans = fac(n, r, N) * pow(fac(r, r, N), N - 2, N) % N +    return ans + + +ans = combi(n, r, N)