from sys import stdin, setrecursionlimit



setrecursionlimit(10 ** 9)

INF = 1 << 60





def input():

    return stdin.readline().strip()





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



if (X + Y) % 3:

    print((0))

    exit()



n = (X + Y) // 3

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

y = (-X + 2 * Y) // 3

if x < 0 or y < 0:

    print((0))

    exit()



MOD = 1000000007

COM_MAX = n



fac, finv, inv = [0] * (COM_MAX + 1), [0] * (COM_MAX + 1), [0] * (COM_MAX + 1)

fac[0] = fac[1] = 1

finv[0] = finv[1] = 1

inv[1] = 1



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

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

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

    finv[i] = finv[i - 1] * inv[i] % MOD





def mod_com(n, k):

    if n < k:

        return 0

    if n < 0 or k < 0:

        return 0

    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD





print((mod_com(n, x)))

from sys import stdin, setrecursionlimit



setrecursionlimit(10 ** 9)

INF = 1 << 60





def input():

    return stdin.readline().strip()





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



n = (X + Y) // 3

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

y = (-X + 2 * Y) // 3

if (X + Y) % 3 or x < 0 or y < 0:

    print((0))

    exit()



MOD = 1000000007

COM_MAX = n



fac, finv, inv = [0] * (COM_MAX + 1), [0] * (COM_MAX + 1), [0] * (COM_MAX + 1)

fac[0] = fac[1] = 1

finv[0] = finv[1] = 1

inv[1] = 1



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

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

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

    finv[i] = finv[i - 1] * inv[i] % MOD





def mod_com(n, k):

    if n < k:

        return 0

    if n < 0 or k < 0:

        return 0

    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD





print((mod_com(n, x)))

from sys import stdin, setrecursionlimit

setrecursionlimit(10**9)
INF = 1 << 60


def input():
    return stdin.readline().strip()


X, Y = list(map(int, input().split()))
if (X + Y) % 3:
    print((0))
    exit()
n = (X + Y) // 3
x = (2 * X - Y) // 3
y = (-X + 2 * Y) // 3
if x < 0 or y < 0:
    print((0))
    exit()
MOD = 1000000007
COM_MAX = n
fac, finv, inv = [0] * (COM_MAX + 1), [0] * (COM_MAX + 1), [0] * (COM_MAX + 1)
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1
for i in range(2, COM_MAX + 1):
    fac[i] = fac[i - 1] * i % MOD
    inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
    finv[i] = finv[i - 1] * inv[i] % MOD


def mod_com(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD


print((mod_com(n, x)))

from sys import stdin, setrecursionlimit

setrecursionlimit(10**9)
INF = 1 << 60


def input():
    return stdin.readline().strip()


X, Y = list(map(int, input().split()))
n = (X + Y) // 3
x = (2 * X - Y) // 3
y = (-X + 2 * Y) // 3
if (X + Y) % 3 or x < 0 or y < 0:
    print((0))
    exit()
MOD = 1000000007
COM_MAX = n
fac, finv, inv = [0] * (COM_MAX + 1), [0] * (COM_MAX + 1), [0] * (COM_MAX + 1)
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1
for i in range(2, COM_MAX + 1):
    fac[i] = fac[i - 1] * i % MOD
    inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
    finv[i] = finv[i - 1] * inv[i] % MOD


def mod_com(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD


print((mod_com(n, x)))

-if (X + Y) % 3: -    print((0)) -    exit() -if x < 0 or y < 0: +if (X + Y) % 3 or x < 0 or y < 0: