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

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 )







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



a =  (  2 * x -  y )

b =  ( - x + 2 * y )



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

    print((0))

    exit(0)



a = int(a/3)

b = int(b/3)



# print(a, b)



mod = 10**9 + 7 



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



print(ans)
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

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 )



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



a =    2 * x -  y 

b =   - x + 2 * y 



ans = 0

if a % 3 == 0 and b % 3 == 0:

    a = a//3

    b = b//3

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

print(ans)
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
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)
x, y = list(map(int, input().split()))
a = 2 * x - y
b = -x + 2 * y
if a % 3 != 0 or b % 3 != 0:
    print((0))
    exit(0)
a = int(a / 3)
b = int(b / 3)
# print(a, b)
mod = 10**9 + 7
ans = cmb((a + b), a, mod)
print(ans)

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
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)
x, y = list(map(int, input().split()))
a = 2 * x - y
b = -x + 2 * y
ans = 0
if a % 3 == 0 and b % 3 == 0:
    a = a // 3
    b = b // 3
    ans = cmb(a + b, a, mod)
print(ans)

-if a % 3 != 0 or b % 3 != 0: -    print((0)) -    exit(0) -a = int(a / 3) -b = int(b / 3) -# print(a, b) -mod = 10**9 + 7 -ans = cmb((a + b), a, mod) +ans = 0 +if a % 3 == 0 and b % 3 == 0: +    a = a // 3 +    b = b // 3 +    ans = cmb(a + b, a, mod)