# 階乗は英語でfactrial, ifacは階乗に対する逆元

def cmb(n, k, mod, fac, ifac):

    # nCkを求める

    k = min(k, n-k)

    return fac[n] * ifac[k] * ifac[n-k] % mod





def make_tables(mod, n):  # (mod mod)の世界における割り算に従ってテーブルを作る

    # 階乗, 階乗に対する逆元のテーブルを作成する

    fac = [1, 1]  # 階乗デーブル

    ifac = [1, 1]  # 階乗に対する逆元のテーブル

    inverse = [0, 1]  # 逆元そのもののテーブル



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

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

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

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

    return fac, ifac





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

MOD = 1000000007

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

    print((0))

else:

    m = (2*X-Y)//3

    n = X - 2*m

    if n < 0 or m < 0:

        print((0))

        exit()

    fac, ifac = make_tables(MOD, (X+Y)//3)

    ans = cmb(n+m, n, MOD, fac, ifac)

    print(ans)

# 二項係数を"やるだけ"にしてくれるライブラリ

from collections import Counter

MAX = 1000010

MOD = 10**9+7

factrial = [0]*MAX

inverse = [0]*MAX

factrial_inverse = [0]*MAX





# テーブルを作る前処理

def COMinit():

    global factrial, inverse, factrial_inverse

    factrial[0] = 1

    factrial[1] = 1

    inverse[1] = 1

    factrial_inverse[0] = 1

    factrial_inverse[1] = 1

    for i in range(2, MAX):

        factrial[i] = factrial[i-1] * i % MOD

        inverse[i] = MOD - inverse[MOD % i] * (MOD//i) % MOD

        factrial_inverse[i] = factrial_inverse[i-1] * inverse[i] % MOD





# 二項係数計算

def COM(n, k):

    global factrial, inverse, factrial_inverse

    if n < k:

        return 0

    if n < 0 or k < 0:

        return 0

    return factrial[n] * (factrial_inverse[k] * factrial_inverse[n-k] % MOD) % MOD





# 前処理完了

COMinit()



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

ans = 0

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

    print((0))

else:

    ans = 0

    m = (2*X - Y) // 3

    n = X - 2*m

    if m < 0 or n < 0:

        print((0))

    else:

        print((COM(n+m, n)))

# 階乗は英語でfactrial, ifacは階乗に対する逆元
def cmb(n, k, mod, fac, ifac):
    # nCkを求める
    k = min(k, n - k)
    return fac[n] * ifac[k] * ifac[n - k] % mod


def make_tables(mod, n):  # (mod mod)の世界における割り算に従ってテーブルを作る
    # 階乗, 階乗に対する逆元のテーブルを作成する
    fac = [1, 1]  # 階乗デーブル
    ifac = [1, 1]  # 階乗に対する逆元のテーブル
    inverse = [0, 1]  # 逆元そのもののテーブル
    for i in range(2, n + 1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod // i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac


X, Y = list(map(int, input().split()))
MOD = 1000000007
if (X + Y) % 3 != 0:
    print((0))
else:
    m = (2 * X - Y) // 3
    n = X - 2 * m
    if n < 0 or m < 0:
        print((0))
        exit()
    fac, ifac = make_tables(MOD, (X + Y) // 3)
    ans = cmb(n + m, n, MOD, fac, ifac)
    print(ans)

# 二項係数を"やるだけ"にしてくれるライブラリ
from collections import Counter

MAX = 1000010
MOD = 10**9 + 7
factrial = [0] * MAX
inverse = [0] * MAX
factrial_inverse = [0] * MAX
# テーブルを作る前処理
def COMinit():
    global factrial, inverse, factrial_inverse
    factrial[0] = 1
    factrial[1] = 1
    inverse[1] = 1
    factrial_inverse[0] = 1
    factrial_inverse[1] = 1
    for i in range(2, MAX):
        factrial[i] = factrial[i - 1] * i % MOD
        inverse[i] = MOD - inverse[MOD % i] * (MOD // i) % MOD
        factrial_inverse[i] = factrial_inverse[i - 1] * inverse[i] % MOD


# 二項係数計算
def COM(n, k):
    global factrial, inverse, factrial_inverse
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return factrial[n] * (factrial_inverse[k] * factrial_inverse[n - k] % MOD) % MOD


# 前処理完了
COMinit()
X, Y = list(map(int, input().split()))
ans = 0
if (X + Y) % 3 != 0:
    print((0))
else:
    ans = 0
    m = (2 * X - Y) // 3
    n = X - 2 * m
    if m < 0 or n < 0:
        print((0))
    else:
        print((COM(n + m, n)))

-# 階乗は英語でfactrial, ifacは階乗に対する逆元 -def cmb(n, k, mod, fac, ifac): -    # nCkを求める -    k = min(k, n - k) -    return fac[n] * ifac[k] * ifac[n - k] % mod +# 二項係数を"やるだけ"にしてくれるライブラリ +from collections import Counter + +MAX = 1000010 +MOD = 10**9 + 7 +factrial = [0] * MAX +inverse = [0] * MAX +factrial_inverse = [0] * MAX +# テーブルを作る前処理 +def COMinit(): +    global factrial, inverse, factrial_inverse +    factrial[0] = 1 +    factrial[1] = 1 +    inverse[1] = 1 +    factrial_inverse[0] = 1 +    factrial_inverse[1] = 1 +    for i in range(2, MAX): +        factrial[i] = factrial[i - 1] * i % MOD +        inverse[i] = MOD - inverse[MOD % i] * (MOD // i) % MOD +        factrial_inverse[i] = factrial_inverse[i - 1] * inverse[i] % MOD -def make_tables(mod, n):  # (mod mod)の世界における割り算に従ってテーブルを作る -    # 階乗, 階乗に対する逆元のテーブルを作成する -    fac = [1, 1]  # 階乗デーブル -    ifac = [1, 1]  # 階乗に対する逆元のテーブル -    inverse = [0, 1]  # 逆元そのもののテーブル -    for i in range(2, n + 1): -        fac.append((fac[-1] * i) % mod) -        inverse.append((-inverse[mod % i] * (mod // i)) % mod) -        ifac.append((ifac[-1] * inverse[-1]) % mod) -    return fac, ifac +# 二項係数計算 +def COM(n, k): +    global factrial, inverse, factrial_inverse +    if n < k: +        return 0 +    if n < 0 or k < 0: +        return 0 +    return factrial[n] * (factrial_inverse[k] * factrial_inverse[n - k] % MOD) % MOD +# 前処理完了 +COMinit() -MOD = 1000000007 +ans = 0 +    ans = 0 -    if n < 0 or m < 0: +    if m < 0 or n < 0: -        exit() -    fac, ifac = make_tables(MOD, (X + Y) // 3) -    ans = cmb(n + m, n, MOD, fac, ifac) -    print(ans) +    else: +        print((COM(n + m, n)))