def comb(n, k, mod):

    if k > (n // 2):

        k = n - k

    a = 1

    for i in range(k):

        a *= (n - i)

        a %= mod

    for i in range(k - 1):

        a = (a * pow(k - i, mod - 2, mod)) % mod



    return a



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

ans = 0

mod = 10 ** 9 + 7

if X > Y:

    X, Y = Y, X

##Yのほうが大きいとして考える

if not (X + Y) % 3 == 0 or Y > 2 * X:

    ans = 0

else:

    n = (X + Y) // 3

    d = Y - X

    a = 2*n - X

    ans = comb(n, a, mod)

print(ans)

def comb(n, k, mod):

    if k > (n // 2):

        k = n - k

    a = 1

    for i in range(k):

        a = (a * (n - i)) % mod

    b = 1

    for i in range(k - 1):

        b = (b *(k - i)) % mod

    a = (a * pow(b, mod - 2, mod)) % mod

    return a





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

ans = 0

mod = 10 ** 9 + 7

if X > Y:

    X, Y = Y, X

##Yのほうが大きいとして考える

if not (X + Y) % 3 == 0 or Y > 2 * X:

    ans = 0

else:

    n = (X + Y) // 3

    d = Y - X

    a = 2*n - X

    ans = comb(n, a, mod)

print(ans)

def comb(n, k, mod):
    if k > (n // 2):
        k = n - k
    a = 1
    for i in range(k):
        a *= n - i
        a %= mod
    for i in range(k - 1):
        a = (a * pow(k - i, mod - 2, mod)) % mod
    return a


X, Y = list(map(int, input().split()))
ans = 0
mod = 10**9 + 7
if X > Y:
    X, Y = Y, X
##Yのほうが大きいとして考える
if not (X + Y) % 3 == 0 or Y > 2 * X:
    ans = 0
else:
    n = (X + Y) // 3
    d = Y - X
    a = 2 * n - X
    ans = comb(n, a, mod)
print(ans)

def comb(n, k, mod):
    if k > (n // 2):
        k = n - k
    a = 1
    for i in range(k):
        a = (a * (n - i)) % mod
    b = 1
    for i in range(k - 1):
        b = (b * (k - i)) % mod
    a = (a * pow(b, mod - 2, mod)) % mod
    return a


X, Y = list(map(int, input().split()))
ans = 0
mod = 10**9 + 7
if X > Y:
    X, Y = Y, X
##Yのほうが大きいとして考える
if not (X + Y) % 3 == 0 or Y > 2 * X:
    ans = 0
else:
    n = (X + Y) // 3
    d = Y - X
    a = 2 * n - X
    ans = comb(n, a, mod)
print(ans)

-        a *= n - i -        a %= mod +        a = (a * (n - i)) % mod +    b = 1 -        a = (a * pow(k - i, mod - 2, mod)) % mod +        b = (b * (k - i)) % mod +    a = (a * pow(b, mod - 2, mod)) % mod