def cmb(n, r, mod):

    if r < 0 or r > n:

        return 0

    r = min(r, n - r)

    return g1[n] * g2[r] * g2[n - r] % mod





mod = 10 ** 9 + 7  # 出力の制限

N = 10 ** 6

g1 = [1, 1]  # 元テーブル

g2 = [1, 1]  # 逆元テーブル

inverse = [0, 1]  # 逆元テーブル計算用テーブル



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

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

    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )

    g2.append( (g2[-1] * inverse[-1]) % mod )





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





if (x+y) % 3 != 0:

    print((0))

    exit()



count = (x+y)//3

x -= count

y -= count



ans = cmb(x+y, min(x, y), mod)

print(ans)
def nCr(n,r,mod = 10**9+7):

    r = min(n-r,r)

    numer = denom = 1

    for i in range(1,r+1):

        numer = numer * (n+1-i) %mod

        denom = denom * i % mod

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





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





if (x+y) % 3 != 0:

    print((0))

    exit()



count = (x+y)//3

x -= count

y -= count



if x<0 or y<0:

    print((0))

    exit()



ans = nCr(x+y, x)

print(ans)

def cmb(n, r, mod):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod


mod = 10**9 + 7  # 出力の制限
N = 10**6
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル
for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)
x, y = list(map(int, input().split()))
if (x + y) % 3 != 0:
    print((0))
    exit()
count = (x + y) // 3
x -= count
y -= count
ans = cmb(x + y, min(x, y), mod)
print(ans)

def nCr(n, r, mod=10**9 + 7):
    r = min(n - r, r)
    numer = denom = 1
    for i in range(1, r + 1):
        numer = numer * (n + 1 - i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod - 2, mod) % mod


x, y = list(map(int, input().split()))
if (x + y) % 3 != 0:
    print((0))
    exit()
count = (x + y) // 3
x -= count
y -= count
if x < 0 or y < 0:
    print((0))
    exit()
ans = nCr(x + y, x)
print(ans)

-def cmb(n, r, mod): -    if r < 0 or r > n: -        return 0 -    r = min(r, n - r) -    return g1[n] * g2[r] * g2[n - r] % mod +def nCr(n, r, mod=10**9 + 7): +    r = min(n - r, r) +    numer = denom = 1 +    for i in range(1, r + 1): +        numer = numer * (n + 1 - i) % mod +        denom = denom * i % mod +    return numer * pow(denom, mod - 2, mod) % mod -mod = 10**9 + 7  # 出力の制限 -N = 10**6 -g1 = [1, 1]  # 元テーブル -g2 = [1, 1]  # 逆元テーブル -inverse = [0, 1]  # 逆元テーブル計算用テーブル -for i in range(2, N + 1): -    g1.append((g1[-1] * i) % mod) -    inverse.append((-inverse[mod % i] * (mod // i)) % mod) -    g2.append((g2[-1] * inverse[-1]) % mod) -ans = cmb(x + y, min(x, y), mod) +if x < 0 or y < 0: +    print((0)) +    exit() +ans = nCr(x + y, x)