# D - Knight



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

####



a = (2*Y - X) / 3

b = (2*X - Y) / 3



# https://qiita.com/derodero24/items/91b6468e66923a87f39f

def cmb(n, r, mod):

    if ( r<0 or r>n ):

        return 0

    r = min(r, n-r)

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



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

N = 10**6

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 )



if a%1 != 0 or b%1 != 0:

    print((0))

else:

    ans = cmb(int(a+b), int(min(a,b)), mod)

    print(ans)

# D - Knight



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

####



a = (2*Y - X) / 3

b = (2*X - Y) / 3



# https://qiita.com/derodero24/items/91b6468e66923a87f39f

# を一部修正

def cmb(n, r, mod):

    if ( r<0 or r>n ):

        return 0

    r = min(r, n-r)

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



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

N = int(a+b)

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

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

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



if a%1 != 0 or b%1 != 0:

    print((0))

else:

    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(int(a+b), int(min(a,b)), mod)

    print(ans)

# D - Knight
X, Y = list(map(int, input().split()))
####
a = (2 * Y - X) / 3
b = (2 * X - Y) / 3
# https://qiita.com/derodero24/items/91b6468e66923a87f39f
def cmb(n, r, mod):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] % mod * g2[n - r] % mod


mod = 10**9 + 7  # 出力の制限
N = 10**6
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)
if a % 1 != 0 or b % 1 != 0:
    print((0))
else:
    ans = cmb(int(a + b), int(min(a, b)), mod)
    print(ans)

# D - Knight
X, Y = list(map(int, input().split()))
####
a = (2 * Y - X) / 3
b = (2 * X - Y) / 3
# https://qiita.com/derodero24/items/91b6468e66923a87f39f
# を一部修正
def cmb(n, r, mod):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] % mod * g2[n - r] % mod


mod = 10**9 + 7  # 出力の制限
N = int(a + b)
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル
if a % 1 != 0 or b % 1 != 0:
    print((0))
else:
    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(int(a + b), int(min(a, b)), mod)
    print(ans)

+# を一部修正 -N = 10**6 +N = int(a + b) -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) +    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)