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



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

  print((0))

  exit()



n=(X+Y)//3

k=Y-(X+Y)//3



if k<0 or k>n:

  print((0))

  exit()

  

#print("n,k:",n,k)

print((cmb(n,k,mod)))
X, Y = list(map(int, input().split()))

MOD = 10 ** 9 + 7



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

    print((0))

    exit()

if abs(X - Y) > (X + Y) // 3:

    print((0))

    exit()

    

n = (X + Y) // 3 + 1

k = ((X - Y) + n + 1) // 2





SIZE = max(n, k)



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

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

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



def comb(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, SIZE):

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

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

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



print((comb(n - 1, k - 1, MOD)))
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()))
if (X + Y) % 3 != 0:
    print((0))
    exit()
n = (X + Y) // 3
k = Y - (X + Y) // 3
if k < 0 or k > n:
    print((0))
    exit()
# print("n,k:",n,k)
print((cmb(n, k, mod)))

X, Y = list(map(int, input().split()))
MOD = 10**9 + 7
if (X + Y) % 3 != 0:
    print((0))
    exit()
if abs(X - Y) > (X + Y) // 3:
    print((0))
    exit()
n = (X + Y) // 3 + 1
k = ((X - Y) + n + 1) // 2
SIZE = max(n, k)
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル


def comb(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, SIZE):
    g1.append((g1[-1] * i) % MOD)
    inverse.append((-inverse[MOD % i] * (MOD // i)) % MOD)
    g2.append((g2[-1] * inverse[-1]) % MOD)
print((comb(n - 1, k - 1, MOD)))

-def cmb(n, r, mod): +X, Y = list(map(int, input().split())) +MOD = 10**9 + 7 +if (X + Y) % 3 != 0: +    print((0)) +    exit() +if abs(X - Y) > (X + Y) // 3: +    print((0)) +    exit() +n = (X + Y) // 3 + 1 +k = ((X - Y) + n + 1) // 2 +SIZE = max(n, k) +g1 = [1, 1]  # 元テーブル +g2 = [1, 1]  # 逆元テーブル +inverse = [0, 1]  # 逆元テーブル計算用テーブル + + +def comb(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())) -if (X + Y) % 3 != 0: -    print((0)) -    exit() -n = (X + Y) // 3 -k = Y - (X + Y) // 3 -if k < 0 or k > n: -    print((0)) -    exit() -# print("n,k:",n,k) -print((cmb(n, k, mod))) +for i in range(2, SIZE): +    g1.append((g1[-1] * i) % MOD) +    inverse.append((-inverse[MOD % i] * (MOD // i)) % MOD) +    g2.append((g2[-1] * inverse[-1]) % MOD) +print((comb(n - 1, k - 1, MOD)))