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

  k = min(k,n-k)

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



def tables(mod, n):

  fac = [1, 1] 

  infac = [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)

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

  return fac,infac



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



if X > Y:

  X, Y = Y, X



move = X + Y



if move % 3 != 0:

  print((0))

else:

  total = move // 3

  n = X - total

  

  if n < 0:

    print((0))

    

  else:

    MOD = 10 ** 9 + 7

    fac, infac = tables(MOD, total)

    ans = cmb(total, n, MOD, fac, infac)

    

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

M = max(X,Y)

m = min(X,Y)

mod = 10 ** 9 + 7



con = (X + Y) // 3

dif = M - m

n = (con - dif) // 2



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

  print((0))

  

else:

  def comb(n, r):

    n += 1

    over = 1

    under = 1

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

      over = over * (n - i) % mod

      under = under * i % mod

    #powでunder ** (mod - 2) % modを実現、逆元を求めている

    return over * pow(under,mod - 2,mod) % mod

  

  ans = comb(con,n)

  

  print(ans)
def cmb(n, k, mod, fac, infac):
    k = min(k, n - k)
    return fac[n] * infac[k] * infac[n - k] % mod


def tables(mod, n):
    fac = [1, 1]
    infac = [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)
        infac.append((infac[-1] * inverse[-1]) % mod)
    return fac, infac


X, Y = list(map(int, input().split()))
if X > Y:
    X, Y = Y, X
move = X + Y
if move % 3 != 0:
    print((0))
else:
    total = move // 3
    n = X - total
    if n < 0:
        print((0))
    else:
        MOD = 10**9 + 7
        fac, infac = tables(MOD, total)
        ans = cmb(total, n, MOD, fac, infac)
        print(ans)

X, Y = list(map(int, input().split()))
M = max(X, Y)
m = min(X, Y)
mod = 10**9 + 7
con = (X + Y) // 3
dif = M - m
n = (con - dif) // 2
if (X + Y) % 3 != 0 or n < 0:
    print((0))
else:

    def comb(n, r):
        n += 1
        over = 1
        under = 1
        for i in range(1, r + 1):
            over = over * (n - i) % mod
            under = under * i % mod
        # powでunder ** (mod - 2) % modを実現、逆元を求めている
        return over * pow(under, mod - 2, mod) % mod

    ans = comb(con, n)
    print(ans)

-def cmb(n, k, mod, fac, infac): -    k = min(k, n - k) -    return fac[n] * infac[k] * infac[n - k] % mod - - -def tables(mod, n): -    fac = [1, 1] -    infac = [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) -        infac.append((infac[-1] * inverse[-1]) % mod) -    return fac, infac - - -if X > Y: -    X, Y = Y, X -move = X + Y -if move % 3 != 0: +M = max(X, Y) +m = min(X, Y) +mod = 10**9 + 7 +con = (X + Y) // 3 +dif = M - m +n = (con - dif) // 2 +if (X + Y) % 3 != 0 or n < 0: -    total = move // 3 -    n = X - total -    if n < 0: -        print((0)) -    else: -        MOD = 10**9 + 7 -        fac, infac = tables(MOD, total) -        ans = cmb(total, n, MOD, fac, infac) -        print(ans) + +    def comb(n, r): +        n += 1 +        over = 1 +        under = 1 +        for i in range(1, r + 1): +            over = over * (n - i) % mod +            under = under * i % mod +        # powでunder ** (mod - 2) % modを実現、逆元を求めている +        return over * pow(under, mod - 2, mod) % mod + +    ans = comb(con, n) +    print(ans)