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



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

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



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

N = max(n+m,n)

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

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

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



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



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 )

    

if (-X+2*Y)%3 == 0 and (2*X-Y)%3 == 0:

    print((cmb(n+m,n,mod)))

else:

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



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

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

MOD = 10**9+7

    

def comb(n,r,MOD):

    x = n+1

    y = min(r,n-r)

    

    numer = 1

    denom = 1

    

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

        numer = numer*(x-i)%MOD

        denom = denom*(i)%MOD

    

    return numer * pow(denom,MOD-2,MOD) % MOD

  

import sys



if n < 0 or m < 0:

    print((0))

    sys.exit()

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

    print((0))

    sys.exit()

    

print((comb(n+m,n,MOD)))
X, Y = list(map(int, input().split()))
n = (-X + 2 * Y) // 3
m = (2 * X - Y) // 3
mod = 10**9 + 7  # 出力の制限
N = max(n + m, n)
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル


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


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)
if (-X + 2 * Y) % 3 == 0 and (2 * X - Y) % 3 == 0:
    print((cmb(n + m, n, mod)))
else:
    print((0))

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


def comb(n, r, MOD):
    x = n + 1
    y = min(r, n - r)
    numer = 1
    denom = 1
    for i in range(1, r + 1):
        numer = numer * (x - i) % MOD
        denom = denom * (i) % MOD
    return numer * pow(denom, MOD - 2, MOD) % MOD


import sys

if n < 0 or m < 0:
    print((0))
    sys.exit()
if (X + Y) % 3 != 0:
    print((0))
    sys.exit()
print((comb(n + m, n, MOD)))

-mod = 10**9 + 7  # 出力の制限 -N = max(n + m, n) -g1 = [1, 1]  # 元テーブル -g2 = [1, 1]  # 逆元テーブル -inverse = [0, 1]  # 逆元テーブル計算用テーブル +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 +def comb(n, r, MOD): +    x = n + 1 +    y = min(r, n - r) +    numer = 1 +    denom = 1 +    for i in range(1, r + 1): +        numer = numer * (x - i) % MOD +        denom = denom * (i) % MOD +    return numer * pow(denom, MOD - 2, MOD) % MOD -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) -if (-X + 2 * Y) % 3 == 0 and (2 * X - Y) % 3 == 0: -    print((cmb(n + m, n, mod))) -else: +import sys + +if n < 0 or m < 0: +    sys.exit() +if (X + Y) % 3 != 0: +    print((0)) +    sys.exit() +print((comb(n + m, n, MOD)))