MOD = 10**9+7



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

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

    print((0))

    exit()

N = (X+Y)//3

X -= N

Y -= N

if X < 0 or Y < 0:

    print((0))

    exit()

si = 1

bo = 1

for i in range(N):

    si = (si*(i+1)) % MOD

for i in range(min(X,Y)):

    bo = (bo*(i+1)) % MOD

for i in range(N-min(X,Y)):

    bo = (bo*(i+1)) % MOD

print(((si*pow(bo,MOD-2,MOD))%MOD))
MOD = 10**9+7         # 問題に合わせて適宜書き換え

list_size = 10**6+100  # 問題に合わせて適宜書き換え



f_list = [1] * list_size

f_r_list = [1] * list_size



for i in range(list_size - 1):

	f_list[i + 1] = ((f_list[i] * (i+2)) % MOD)



f_r_list[-1] = pow(f_list[-1], MOD - 2, MOD)



for i in range(-2, -list_size-1, -1):

	f_r_list[i] = ((f_r_list[i+1] * (list_size + 2 + i)) % MOD)



def comb(n,r):

    if r == 0 or n == r:

        return 1

    return (((f_list[n - 1] * f_r_list[n - r - 1]) % MOD) * f_r_list[r - 1]) % MOD



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

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

    print((0))

    exit()

N = (X+Y)//3

X -= N

Y -= N

if X < 0 or Y < 0:

    print((0))

    exit()

print((comb(N,X)))

MOD = 10**9 + 7
X, Y = list(map(int, input().split()))
if (X + Y) % 3 != 0:
    print((0))
    exit()
N = (X + Y) // 3
X -= N
Y -= N
if X < 0 or Y < 0:
    print((0))
    exit()
si = 1
bo = 1
for i in range(N):
    si = (si * (i + 1)) % MOD
for i in range(min(X, Y)):
    bo = (bo * (i + 1)) % MOD
for i in range(N - min(X, Y)):
    bo = (bo * (i + 1)) % MOD
print(((si * pow(bo, MOD - 2, MOD)) % MOD))

MOD = 10**9 + 7  # 問題に合わせて適宜書き換え
list_size = 10**6 + 100  # 問題に合わせて適宜書き換え
f_list = [1] * list_size
f_r_list = [1] * list_size
for i in range(list_size - 1):
    f_list[i + 1] = (f_list[i] * (i + 2)) % MOD
f_r_list[-1] = pow(f_list[-1], MOD - 2, MOD)
for i in range(-2, -list_size - 1, -1):
    f_r_list[i] = (f_r_list[i + 1] * (list_size + 2 + i)) % MOD


def comb(n, r):
    if r == 0 or n == r:
        return 1
    return (((f_list[n - 1] * f_r_list[n - r - 1]) % MOD) * f_r_list[r - 1]) % MOD


X, Y = list(map(int, input().split()))
if (X + Y) % 3 != 0:
    print((0))
    exit()
N = (X + Y) // 3
X -= N
Y -= N
if X < 0 or Y < 0:
    print((0))
    exit()
print((comb(N, X)))

-MOD = 10**9 + 7 +MOD = 10**9 + 7  # 問題に合わせて適宜書き換え +list_size = 10**6 + 100  # 問題に合わせて適宜書き換え +f_list = [1] * list_size +f_r_list = [1] * list_size +for i in range(list_size - 1): +    f_list[i + 1] = (f_list[i] * (i + 2)) % MOD +f_r_list[-1] = pow(f_list[-1], MOD - 2, MOD) +for i in range(-2, -list_size - 1, -1): +    f_r_list[i] = (f_r_list[i + 1] * (list_size + 2 + i)) % MOD + + +def comb(n, r): +    if r == 0 or n == r: +        return 1 +    return (((f_list[n - 1] * f_r_list[n - r - 1]) % MOD) * f_r_list[r - 1]) % MOD + + -si = 1 -bo = 1 -for i in range(N): -    si = (si * (i + 1)) % MOD -for i in range(min(X, Y)): -    bo = (bo * (i + 1)) % MOD -for i in range(N - min(X, Y)): -    bo = (bo * (i + 1)) % MOD -print(((si * pow(bo, MOD - 2, MOD)) % MOD)) +print((comb(N, X)))