from functools import reduce

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

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

y = (2*X-Y) /3

#ans=0のときをどっかで書く。indentめんどいからどうする？

MOD = 10**9+7

if int(x) == x and int(y) == y and x>=0 and y>=0 :

  sum1 = int(x+y)

  bunbo = min([int(x),int(y)])

  n1 = reduce(lambda a,b : (a*b) % MOD  ,list(range(sum1,sum1-bunbo,-1)),1)

  n2 = reduce(lambda a,b : (a*b) % MOD ,list(range(bunbo,1,-1)),1)

  n2inv = pow(n2,MOD-2,MOD) 

  print(((n1*n2inv) % MOD))

else:

  print((0))
from functools import reduce

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

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

y = (2*X-Y) /3

MOD = 10**9+7



def mod_comb(n,m,mod):

  def mod_mult(a,b,mod1=mod):

    return (a*b) % mod1

  n1 = reduce(mod_mult ,list(range(n,n-m,-1)),1)

  n2 = reduce(mod_mult ,list(range(m,1,-1)),1)

  n2inv = pow(n2,mod-2,mod) 

  return ((n1*n2inv) % mod)





if int(x) == x and int(y) == y and x>=0 and y>=0 :

  sum1 = int(x+y)

  bunbo = min([int(x),int(y)])

  print((mod_comb(sum1,bunbo,MOD)))

else:

  print((0))

  
from functools import reduce

X, Y = list(map(int, input().split()))
x = (-X + 2 * Y) / 3
y = (2 * X - Y) / 3
# ans=0のときをどっかで書く。indentめんどいからどうする？
MOD = 10**9 + 7
if int(x) == x and int(y) == y and x >= 0 and y >= 0:
    sum1 = int(x + y)
    bunbo = min([int(x), int(y)])
    n1 = reduce(lambda a, b: (a * b) % MOD, list(range(sum1, sum1 - bunbo, -1)), 1)
    n2 = reduce(lambda a, b: (a * b) % MOD, list(range(bunbo, 1, -1)), 1)
    n2inv = pow(n2, MOD - 2, MOD)
    print(((n1 * n2inv) % MOD))
else:
    print((0))

from functools import reduce

X, Y = list(map(int, input().split()))
x = (-X + 2 * Y) / 3
y = (2 * X - Y) / 3
MOD = 10**9 + 7


def mod_comb(n, m, mod):
    def mod_mult(a, b, mod1=mod):
        return (a * b) % mod1

    n1 = reduce(mod_mult, list(range(n, n - m, -1)), 1)
    n2 = reduce(mod_mult, list(range(m, 1, -1)), 1)
    n2inv = pow(n2, mod - 2, mod)
    return (n1 * n2inv) % mod


if int(x) == x and int(y) == y and x >= 0 and y >= 0:
    sum1 = int(x + y)
    bunbo = min([int(x), int(y)])
    print((mod_comb(sum1, bunbo, MOD)))
else:
    print((0))

-# ans=0のときをどっかで書く。indentめんどいからどうする？ + + +def mod_comb(n, m, mod): +    def mod_mult(a, b, mod1=mod): +        return (a * b) % mod1 + +    n1 = reduce(mod_mult, list(range(n, n - m, -1)), 1) +    n2 = reduce(mod_mult, list(range(m, 1, -1)), 1) +    n2inv = pow(n2, mod - 2, mod) +    return (n1 * n2inv) % mod + + -    n1 = reduce(lambda a, b: (a * b) % MOD, list(range(sum1, sum1 - bunbo, -1)), 1) -    n2 = reduce(lambda a, b: (a * b) % MOD, list(range(bunbo, 1, -1)), 1) -    n2inv = pow(n2, MOD - 2, MOD) -    print(((n1 * n2inv) % MOD)) +    print((mod_comb(sum1, bunbo, MOD)))