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 + 10

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



n = (2 * x - y) / 3

m = (2 * y - x) / 3

mod = 10 ** 9 + 7



if int(n) == n and int(m) == m:

    n = int(n)

    m = int(m)

    ans = cmb(n + m, n, mod)

    ans %= mod

    print(ans)



else:

    print((0))

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

mod = 10 ** 9 + 7



cnt1 = cnt2 = 0

for i in range(x + 1):

    x_left = x - i

    y_left = y - 2 * i

    if x_left == y_left * 2:

        cnt1 = i

        cnt2 = y_left



if cnt1 == cnt2 == 0:

    ans = 0

else:

    ans = 1

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

        ans *= (cnt1 + cnt2 - i + 1)

        ans %= mod

        ans *= pow(i, mod - 2, mod)

        ans %= 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 + 10
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()))
n = (2 * x - y) / 3
m = (2 * y - x) / 3
mod = 10**9 + 7
if int(n) == n and int(m) == m:
    n = int(n)
    m = int(m)
    ans = cmb(n + m, n, mod)
    ans %= mod
    print(ans)
else:
    print((0))

x, y = list(map(int, input().split()))
mod = 10**9 + 7
cnt1 = cnt2 = 0
for i in range(x + 1):
    x_left = x - i
    y_left = y - 2 * i
    if x_left == y_left * 2:
        cnt1 = i
        cnt2 = y_left
if cnt1 == cnt2 == 0:
    ans = 0
else:
    ans = 1
    for i in range(1, cnt1 + 1):
        ans *= cnt1 + cnt2 - i + 1
        ans %= mod
        ans *= pow(i, mod - 2, mod)
        ans %= 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 + 10 -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) -n = (2 * x - y) / 3 -m = (2 * y - x) / 3 -if int(n) == n and int(m) == m: -    n = int(n) -    m = int(m) -    ans = cmb(n + m, n, mod) -    ans %= mod -    print(ans) +cnt1 = cnt2 = 0 +for i in range(x + 1): +    x_left = x - i +    y_left = y - 2 * i +    if x_left == y_left * 2: +        cnt1 = i +        cnt2 = y_left +if cnt1 == cnt2 == 0: +    ans = 0 -    print((0)) +    ans = 1 +    for i in range(1, cnt1 + 1): +        ans *= cnt1 + cnt2 - i + 1 +        ans %= mod +        ans *= pow(i, mod - 2, mod) +        ans %= mod +print(ans)