MOD = 10**9 + 7

def nck(n, k):

    numer, denom = 1, 1

    for i in range(k):

        numer = numer * (n - i) % MOD

        denom = denom * (k - i) % MOD

    return numer * pow(denom, MOD-2, MOD) % MOD



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

# (1, 2) 動く回数をm回、(2, 1) 動く回数をn回とする

n = -1

for m in range(min(x//1, y//2) + 1):

    rx = x - m

    ry = y - 2 * m

    if rx == ry * 2:

        n = ry

        break



if n == -1:

    print((0))

else:

    print((nck(m+n, min(m, n))))

def nck(n, k):

    numer, denom = 1, 1

    for i in range(k):

        numer = numer * (n-i) % MOD

        denom = denom * (k-i) % MOD

    return numer * pow(denom, MOD-2, MOD) % MOD



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

MOD = 10 ** 9 + 7



i = 2 * y - x

j = 2 * x - y

if i % 3 != 0 or j % 3 != 0 or i < 0 or j < 0:

    print((0))

else:

    i, j = i // 3, j // 3

    print((nck(i+j, min(i, j))))

MOD = 10**9 + 7


def nck(n, k):
    numer, denom = 1, 1
    for i in range(k):
        numer = numer * (n - i) % MOD
        denom = denom * (k - i) % MOD
    return numer * pow(denom, MOD - 2, MOD) % MOD


x, y = list(map(int, input().split()))
# (1, 2) 動く回数をm回、(2, 1) 動く回数をn回とする
n = -1
for m in range(min(x // 1, y // 2) + 1):
    rx = x - m
    ry = y - 2 * m
    if rx == ry * 2:
        n = ry
        break
if n == -1:
    print((0))
else:
    print((nck(m + n, min(m, n))))

def nck(n, k):
    numer, denom = 1, 1
    for i in range(k):
        numer = numer * (n - i) % MOD
        denom = denom * (k - i) % MOD
    return numer * pow(denom, MOD - 2, MOD) % MOD


x, y = list(map(int, input().split()))
MOD = 10**9 + 7
i = 2 * y - x
j = 2 * x - y
if i % 3 != 0 or j % 3 != 0 or i < 0 or j < 0:
    print((0))
else:
    i, j = i // 3, j // 3
    print((nck(i + j, min(i, j))))

-MOD = 10**9 + 7 - - -# (1, 2) 動く回数をm回、(2, 1) 動く回数をn回とする -n = -1 -for m in range(min(x // 1, y // 2) + 1): -    rx = x - m -    ry = y - 2 * m -    if rx == ry * 2: -        n = ry -        break -if n == -1: +MOD = 10**9 + 7 +i = 2 * y - x +j = 2 * x - y +if i % 3 != 0 or j % 3 != 0 or i < 0 or j < 0: -    print((nck(m + n, min(m, n)))) +    i, j = i // 3, j // 3 +    print((nck(i + j, min(i, j))))