from math import factorial

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

MOD = 10 ** 9 + 7

#a(1,2)+b(2,1)

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

  ans = 0

  print(ans)

  quit()

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

  ans = 0  

  print(ans)

  quit()



a = int((2 * Y - X) / 3)

b = int((2 * X - Y) / 3)



if (a < 0) or (b < 0):

  ans = 0

  print(ans)

  quit()

  

def cmb(n, r):

    if n - r < r: r = n - r

    if r == 0: return 1

    if r == 1: return n



    numerator = [n - r + k + 1 for k in range(r)]

    denominator = [k + 1 for k in range(r)]



    for p in range(2,r+1):

        pivot = denominator[p - 1]

        if pivot > 1:

            offset = (n - r) % p

            for k in range(p-1,r,p):

                numerator[k - offset] /= pivot

                denominator[k] /= pivot



    result = 1

    for k in range(r):

        if numerator[k] > 1:

            result *= int(numerator[k])



    return result



ans = cmb(a + b,a)



print((int(ans % MOD)))

def cmb(n, r, p):

    if (r < 0) or (n < r):

        return 0

    r = min(r, n - r)

    return fact[n] * factinv[r] * factinv[n-r] % p



p = 10 ** 9 + 7

N = 2 * 10 ** 6  # N は必要分だけ用意する

fact = [1, 1]  # fact[n] = (n! mod p)

factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)

inv = [0, 1]  # factinv 計算用

 

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

    fact.append((fact[-1] * i) % p)

    inv.append((-inv[p % i] * (p // i)) % p)

    factinv.append((factinv[-1] * inv[-1]) % p)



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

#(1, 2)の回数をn, (2, 1)の回数をmとする。

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

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

#いけない場合を除外

if n % 1 != 0:

  print((0))

  quit()

elif m % 1 != 0:

  print((0))

  quit()

#n + m C nで答え  

ans = cmb(int(n + m), int(n), p)

print(ans)





from math import factorial

X, Y = list(map(int, input().split()))
MOD = 10**9 + 7
# a(1,2)+b(2,1)
if (2 * Y - X) % 3 != 0:
    ans = 0
    print(ans)
    quit()
if (2 * X - Y) % 3 != 0:
    ans = 0
    print(ans)
    quit()
a = int((2 * Y - X) / 3)
b = int((2 * X - Y) / 3)
if (a < 0) or (b < 0):
    ans = 0
    print(ans)
    quit()


def cmb(n, r):
    if n - r < r:
        r = n - r
    if r == 0:
        return 1
    if r == 1:
        return n
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
    return result


ans = cmb(a + b, a)
print((int(ans % MOD)))

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p


p = 10**9 + 7
N = 2 * 10**6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
X, Y = list(map(int, input().split()))
# (1, 2)の回数をn, (2, 1)の回数をmとする。
n = (-X + 2 * Y) / 3
m = (-Y + 2 * X) / 3
# いけない場合を除外
if n % 1 != 0:
    print((0))
    quit()
elif m % 1 != 0:
    print((0))
    quit()
# n + m C nで答え
ans = cmb(int(n + m), int(n), p)
print(ans)

-from math import factorial - -X, Y = list(map(int, input().split())) -MOD = 10**9 + 7 -# a(1,2)+b(2,1) -if (2 * Y - X) % 3 != 0: -    ans = 0 -    print(ans) -    quit() -if (2 * X - Y) % 3 != 0: -    ans = 0 -    print(ans) -    quit() -a = int((2 * Y - X) / 3) -b = int((2 * X - Y) / 3) -if (a < 0) or (b < 0): -    ans = 0 -    print(ans) -    quit() +def cmb(n, r, p): +    if (r < 0) or (n < r): +        return 0 +    r = min(r, n - r) +    return fact[n] * factinv[r] * factinv[n - r] % p -def cmb(n, r): -    if n - r < r: -        r = n - r -    if r == 0: -        return 1 -    if r == 1: -        return n -    numerator = [n - r + k + 1 for k in range(r)] -    denominator = [k + 1 for k in range(r)] -    for p in range(2, r + 1): -        pivot = denominator[p - 1] -        if pivot > 1: -            offset = (n - r) % p -            for k in range(p - 1, r, p): -                numerator[k - offset] /= pivot -                denominator[k] /= pivot -    result = 1 -    for k in range(r): -        if numerator[k] > 1: -            result *= int(numerator[k]) -    return result - - -ans = cmb(a + b, a) -print((int(ans % MOD))) +p = 10**9 + 7 +N = 2 * 10**6  # N は必要分だけ用意する +fact = [1, 1]  # fact[n] = (n! mod p) +factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p) +inv = [0, 1]  # factinv 計算用 +for i in range(2, N + 1): +    fact.append((fact[-1] * i) % p) +    inv.append((-inv[p % i] * (p // i)) % p) +    factinv.append((factinv[-1] * inv[-1]) % p) +X, Y = list(map(int, input().split())) +# (1, 2)の回数をn, (2, 1)の回数をmとする。 +n = (-X + 2 * Y) / 3 +m = (-Y + 2 * X) / 3 +# いけない場合を除外 +if n % 1 != 0: +    print((0)) +    quit() +elif m % 1 != 0: +    print((0)) +    quit() +# n + m C nで答え +ans = cmb(int(n + m), int(n), p) +print(ans)