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



if (X+Y)%3 != 0 or X > 2*Y or Y > 2*X:

    print((0))

else:

    ab = (X+Y)//3

    a = X - ab

    b = ab - a

    mod = 10**9+7

    def cmb(n, r, mod):

        if ( r<0 or r>n ):

            return 0

        r = min(r, n-r)

        return g1[n] * g2[r] * g2[n-r] % mod



    mod = 10**9+7 #出力の制限

    N = 10**6+1

    g1 = [1, 1] # 元テーブル

    g2 = [1, 1] #逆元テーブル

    inverse = [0, 1] #逆元テーブル計算用テーブル



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

        g1.append( ( g1[-1] * i ) % mod )

        inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )

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



    ans = cmb(ab,b,mod)

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

def comb(n,k,p):

  """power_funcを用いて(nCk) mod p を求める"""

  from math import factorial

  if n<0 or k<0 or n<k: return 0

  if n==0 or k==0: return 1

  a = 1

  b = 1

  c = 1

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

    a = (a*i)%p

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

    b = (b*i)%p

  for i in range(1,n-k+1):

    c = (c*i)%p

  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p

def power_func(a,b,p):

  """a^b mod p を求める"""

  if b==0: return 1

  if b%2==0:

    d=power_func(a,b//2,p)

    return d*d %p

  if b%2==1:

    return (a*power_func(a,b-1,p ))%p

if (X+Y)%3 != 0 or X > 2*Y or Y > 2*X:

    print((0))

else:

    ab = (X+Y)//3

    a = X - ab

    b = ab - a

    mod = 10**9+7

    ans = comb(ab,min(a,b),mod)

    print(ans)
X, Y = list(map(int, input().split()))
if (X + Y) % 3 != 0 or X > 2 * Y or Y > 2 * X:
    print((0))
else:
    ab = (X + Y) // 3
    a = X - ab
    b = ab - a
    mod = 10**9 + 7

    def cmb(n, r, mod):
        if r < 0 or r > n:
            return 0
        r = min(r, n - r)
        return g1[n] * g2[r] * g2[n - r] % mod

    mod = 10**9 + 7  # 出力の制限
    N = 10**6 + 1
    g1 = [1, 1]  # 元テーブル
    g2 = [1, 1]  # 逆元テーブル
    inverse = [0, 1]  # 逆元テーブル計算用テーブル
    for i in range(2, N + 1):
        g1.append((g1[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod // i)) % mod)
        g2.append((g2[-1] * inverse[-1]) % mod)
    ans = cmb(ab, b, mod)
    print(ans)

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


def comb(n, k, p):
    """power_funcを用いて(nCk) mod p を求める"""
    from math import factorial

    if n < 0 or k < 0 or n < k:
        return 0
    if n == 0 or k == 0:
        return 1
    a = 1
    b = 1
    c = 1
    for i in range(1, n + 1):
        a = (a * i) % p
    for i in range(1, k + 1):
        b = (b * i) % p
    for i in range(1, n - k + 1):
        c = (c * i) % p
    return (a * power_func(b, p - 2, p) * power_func(c, p - 2, p)) % p


def power_func(a, b, p):
    """a^b mod p を求める"""
    if b == 0:
        return 1
    if b % 2 == 0:
        d = power_func(a, b // 2, p)
        return d * d % p
    if b % 2 == 1:
        return (a * power_func(a, b - 1, p)) % p


if (X + Y) % 3 != 0 or X > 2 * Y or Y > 2 * X:
    print((0))
else:
    ab = (X + Y) // 3
    a = X - ab
    b = ab - a
    mod = 10**9 + 7
    ans = comb(ab, min(a, b), mod)
    print(ans)

+ + +def comb(n, k, p): +    """power_funcを用いて(nCk) mod p を求める""" +    from math import factorial + +    if n < 0 or k < 0 or n < k: +        return 0 +    if n == 0 or k == 0: +        return 1 +    a = 1 +    b = 1 +    c = 1 +    for i in range(1, n + 1): +        a = (a * i) % p +    for i in range(1, k + 1): +        b = (b * i) % p +    for i in range(1, n - k + 1): +        c = (c * i) % p +    return (a * power_func(b, p - 2, p) * power_func(c, p - 2, p)) % p + + +def power_func(a, b, p): +    """a^b mod p を求める""" +    if b == 0: +        return 1 +    if b % 2 == 0: +        d = power_func(a, b // 2, p) +        return d * d % p +    if b % 2 == 1: +        return (a * power_func(a, b - 1, p)) % p + + - -    def cmb(n, r, mod): -        if r < 0 or r > n: -            return 0 -        r = min(r, n - r) -        return g1[n] * g2[r] * g2[n - r] % mod - -    mod = 10**9 + 7  # 出力の制限 -    N = 10**6 + 1 -    g1 = [1, 1]  # 元テーブル -    g2 = [1, 1]  # 逆元テーブル -    inverse = [0, 1]  # 逆元テーブル計算用テーブル -    for i in range(2, N + 1): -        g1.append((g1[-1] * i) % mod) -        inverse.append((-inverse[mod % i] * (mod // i)) % mod) -        g2.append((g2[-1] * inverse[-1]) % mod) -    ans = cmb(ab, b, mod) +    ans = comb(ab, min(a, b), mod)