mod = 10**9+7



def pow(n, x):

  if x == 0:

    return 1

  elif x % 2 == 0:

    return pow(n * n % mod, x // 2)

  else:

    return n * pow(n * n % mod, x // 2) % mod



def comb(n, r):

  p, q = 1, 1

  for i in range(r):

    p = p * (n-i) % mod

    q = q * (i+1) % mod

  return p * pow(q, mod-2) % mod



x, y = list(map(int, input().split()))

m = abs(x - y)

n = (x + y) // 3

if (x + y) % 3 == 0 and n >= m:

  print((comb(n, (n + m) // 2)))

else:

  print((0))
mod = 10**9+7



def comb(n, r):

  p, q = 1, 1

  for i in range(r):

    p = p * (n-i) % mod

    q = q * (i+1) % mod

  return p * pow(q, mod-2, mod) % mod



x, y = list(map(int, input().split()))

m = abs(x - y)

n = (x + y) // 3

if (x + y) % 3 == 0 and n >= m:

  print((comb(n, (n - m) // 2)))

else:

  print((0))
mod = 10**9 + 7


def pow(n, x):
    if x == 0:
        return 1
    elif x % 2 == 0:
        return pow(n * n % mod, x // 2)
    else:
        return n * pow(n * n % mod, x // 2) % mod


def comb(n, r):
    p, q = 1, 1
    for i in range(r):
        p = p * (n - i) % mod
        q = q * (i + 1) % mod
    return p * pow(q, mod - 2) % mod


x, y = list(map(int, input().split()))
m = abs(x - y)
n = (x + y) // 3
if (x + y) % 3 == 0 and n >= m:
    print((comb(n, (n + m) // 2)))
else:
    print((0))

mod = 10**9 + 7


def comb(n, r):
    p, q = 1, 1
    for i in range(r):
        p = p * (n - i) % mod
        q = q * (i + 1) % mod
    return p * pow(q, mod - 2, mod) % mod


x, y = list(map(int, input().split()))
m = abs(x - y)
n = (x + y) // 3
if (x + y) % 3 == 0 and n >= m:
    print((comb(n, (n - m) // 2)))
else:
    print((0))

- - -def pow(n, x): -    if x == 0: -        return 1 -    elif x % 2 == 0: -        return pow(n * n % mod, x // 2) -    else: -        return n * pow(n * n % mod, x // 2) % mod -    return p * pow(q, mod - 2) % mod +    return p * pow(q, mod - 2, mod) % mod -    print((comb(n, (n + m) // 2))) +    print((comb(n, (n - m) // 2)))