def nCr(n,r):

  dividend,divisor = 1,1

  for i in range(r):

    dividend *= n-i

    divisor *= 1+i

    dividend %= MOD

    divisor %= MOD



  return (dividend * pow(divisor, MOD-2, MOD)) % MOD



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

INF = 10**15

MOD = 10**9+7



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

  print((0))

  exit()



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

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



if n<0 or m<0:

  print((0))

  exit()



print((nCr(n+m, n)))
def nCr(n,r):

  dividend = 1

  divisor = 1

  MOD = 10**9+7

  d1 = n

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

    dividend *= d1

    divisor *= i

    d1 -= 1

    dividend %= MOD

    divisor %= MOD



  return (dividend * pow(divisor, MOD-2, MOD)) % MOD



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



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

  print((0))

  exit()



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

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



if n<0 or m<0:

  print((0))

else:

  print((nCr(n+m, n)))
def nCr(n, r):
    dividend, divisor = 1, 1
    for i in range(r):
        dividend *= n - i
        divisor *= 1 + i
        dividend %= MOD
        divisor %= MOD
    return (dividend * pow(divisor, MOD - 2, MOD)) % MOD


X, Y = list(map(int, input().split()))
INF = 10**15
MOD = 10**9 + 7
if (X + Y) % 3 != 0:
    print((0))
    exit()
n = (-X + 2 * Y) // 3
m = (2 * X - Y) // 3
if n < 0 or m < 0:
    print((0))
    exit()
print((nCr(n + m, n)))

def nCr(n, r):
    dividend = 1
    divisor = 1
    MOD = 10**9 + 7
    d1 = n
    for i in range(1, r + 1):
        dividend *= d1
        divisor *= i
        d1 -= 1
        dividend %= MOD
        divisor %= MOD
    return (dividend * pow(divisor, MOD - 2, MOD)) % MOD


X, Y = list(map(int, input().split()))
if (X + Y) % 3 != 0:
    print((0))
    exit()
n = (-X + 2 * Y) // 3
m = (2 * X - Y) // 3
if n < 0 or m < 0:
    print((0))
else:
    print((nCr(n + m, n)))

-    dividend, divisor = 1, 1 -    for i in range(r): -        dividend *= n - i -        divisor *= 1 + i +    dividend = 1 +    divisor = 1 +    MOD = 10**9 + 7 +    d1 = n +    for i in range(1, r + 1): +        dividend *= d1 +        divisor *= i +        d1 -= 1 -INF = 10**15 -MOD = 10**9 + 7 -    exit() -print((nCr(n + m, n))) +else: +    print((nCr(n + m, n)))