import math



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 = [int(i) for i in input().split()]



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

    print((0))

elif (2*X - Y) % 3 != 0:

    print((0))

else:

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

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

    print((cmb(x+y, x , mod)))

import math



def cmb(n, r, mod):

    r = min(r, n-r)



    a = 1

    b = 1

    for i in range(r):

        a = (a * (n-i)) % mod

        b = (b * (i+1)) % mod

    

    return a * pow(b, mod-2, mod) % mod



X, Y = [int(i) for i in input().split()]

mod = 10**9+7 

x_tmp = 2*X - Y

y_tmp = 2*Y - X



if x_tmp < 0 or y_tmp < 0:

    ans = 0

elif x_tmp % 3 != 0 or y_tmp % 3 != 0:

    ans = 0

else:

    x = x_tmp // 3

    y = y_tmp // 3

    ans = cmb(x + y, y, mod)



print(ans)
import math


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 = [int(i) for i in input().split()]
if (2 * Y - X) % 3 != 0:
    print((0))
elif (2 * X - Y) % 3 != 0:
    print((0))
else:
    x = (2 * X - Y) // 3
    y = (2 * Y - X) // 3
    print((cmb(x + y, x, mod)))

import math


def cmb(n, r, mod):
    r = min(r, n - r)
    a = 1
    b = 1
    for i in range(r):
        a = (a * (n - i)) % mod
        b = (b * (i + 1)) % mod
    return a * pow(b, mod - 2, mod) % mod


X, Y = [int(i) for i in input().split()]
mod = 10**9 + 7
x_tmp = 2 * X - Y
y_tmp = 2 * Y - X
if x_tmp < 0 or y_tmp < 0:
    ans = 0
elif x_tmp % 3 != 0 or y_tmp % 3 != 0:
    ans = 0
else:
    x = x_tmp // 3
    y = y_tmp // 3
    ans = cmb(x + y, y, mod)
print(ans)

-    if r < 0 or r > n: -        return 0 -    return g1[n] * g2[r] * g2[n - r] % mod +    a = 1 +    b = 1 +    for i in range(r): +        a = (a * (n - i)) % mod +        b = (b * (i + 1)) % mod +    return a * pow(b, mod - 2, mod) % mod +X, Y = [int(i) for i in input().split()] -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 = [int(i) for i in input().split()] -if (2 * Y - X) % 3 != 0: -    print((0)) -elif (2 * X - Y) % 3 != 0: -    print((0)) +x_tmp = 2 * X - Y +y_tmp = 2 * Y - X +if x_tmp < 0 or y_tmp < 0: +    ans = 0 +elif x_tmp % 3 != 0 or y_tmp % 3 != 0: +    ans = 0 -    x = (2 * X - Y) // 3 -    y = (2 * Y - X) // 3 -    print((cmb(x + y, x, mod))) +    x = x_tmp // 3 +    y = y_tmp // 3 +    ans = cmb(x + y, y, mod) +print(ans)