MAX_NUM = 10**6 + 1

MOD = 10**9+7



fac  = [0 for _ in range(MAX_NUM)]

finv = [0 for _ in range(MAX_NUM)]

inv  = [0 for _ in range(MAX_NUM)]



fac[0] = 1

fac[1] = 1

finv[0] = 1

finv[1] = 1

inv[1] = 1



for i in range(2,MAX_NUM):

    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 combinations(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



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



if (-Y + 2*X) % 3 == 0 and (2*Y - X) %3 == 0:

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

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

    

    result = combinations(x+y,min(x,y))

    print((int(result % MOD)))

    

else:

    print((0))

    

MAX_NUM = 10**6 + 1

MOD = 10**9+7



fac  = [0 for _ in range(MAX_NUM)]

finv = [0 for _ in range(MAX_NUM)]

inv  = [0 for _ in range(MAX_NUM)]



fac[0] = 1

fac[1] = 1

finv[0] = 1

finv[1] = 1

inv[1] = 1



for i in range(2,MAX_NUM):

    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 combinations(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



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



if (-Y + 2*X) % 3 != 0 or (2*Y - X) %3 != 0 or (-Y + 2*X) < 0 or (2*Y - X) <0:

    print((0))

else:

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

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

    

    result = combinations(x+y,min(x,y))

    print((int(result % MOD)))

MAX_NUM = 10**6 + 1
MOD = 10**9 + 7
fac = [0 for _ in range(MAX_NUM)]
finv = [0 for _ in range(MAX_NUM)]
inv = [0 for _ in range(MAX_NUM)]
fac[0] = 1
fac[1] = 1
finv[0] = 1
finv[1] = 1
inv[1] = 1
for i in range(2, MAX_NUM):
    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 combinations(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


X, Y = list(map(int, input().split()))
if (-Y + 2 * X) % 3 == 0 and (2 * Y - X) % 3 == 0:
    x = (-Y + 2 * X) // 3
    y = (2 * Y - X) // 3
    result = combinations(x + y, min(x, y))
    print((int(result % MOD)))
else:
    print((0))

MAX_NUM = 10**6 + 1
MOD = 10**9 + 7
fac = [0 for _ in range(MAX_NUM)]
finv = [0 for _ in range(MAX_NUM)]
inv = [0 for _ in range(MAX_NUM)]
fac[0] = 1
fac[1] = 1
finv[0] = 1
finv[1] = 1
inv[1] = 1
for i in range(2, MAX_NUM):
    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 combinations(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


X, Y = list(map(int, input().split()))
if (-Y + 2 * X) % 3 != 0 or (2 * Y - X) % 3 != 0 or (-Y + 2 * X) < 0 or (2 * Y - X) < 0:
    print((0))
else:
    x = (-Y + 2 * X) // 3
    y = (2 * Y - X) // 3
    result = combinations(x + y, min(x, y))
    print((int(result % MOD)))

-if (-Y + 2 * X) % 3 == 0 and (2 * Y - X) % 3 == 0: +if (-Y + 2 * X) % 3 != 0 or (2 * Y - X) % 3 != 0 or (-Y + 2 * X) < 0 or (2 * Y - X) < 0: +    print((0)) +else: -else: -    print((0))