def modinv(a,m):

    return pow(a,m-2,m)



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

if (x+y)%3 != 0 or 2*y-x < 0 or 2*x-y < 0:

    print((0))

else:

    a = (2*y-x)//3

    b = (2*x-y)//3

    ans = 1

    mod = 10**9+7

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

        ans = ans*(i+b)*modinv(i,mod)%mod

    print(ans)

#nCrをmodで割った余りO(r)

def comb(n, r, mod):

    r = min(r, n-r)

    mol = 1

    deno = 1

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

        mol = mol * (n-r+i) % mod

        deno = deno * i % mod

    ret = mol * pow(deno, mod-2, mod) % mod

    return ret



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

if (x+y)%3 != 0 or 2*y-x < 0 or 2*x-y < 0:

    print((0))

else:

    a = (2*y-x)//3

    b = (2*x-y)//3

    mod = 10**9+7

    print((comb(a+b,a,mod)))

def modinv(a, m):
    return pow(a, m - 2, m)


x, y = list(map(int, input().split()))
if (x + y) % 3 != 0 or 2 * y - x < 0 or 2 * x - y < 0:
    print((0))
else:
    a = (2 * y - x) // 3
    b = (2 * x - y) // 3
    ans = 1
    mod = 10**9 + 7
    for i in range(1, a + 1):
        ans = ans * (i + b) * modinv(i, mod) % mod
    print(ans)

# nCrをmodで割った余りO(r)
def comb(n, r, mod):
    r = min(r, n - r)
    mol = 1
    deno = 1
    for i in range(1, r + 1):
        mol = mol * (n - r + i) % mod
        deno = deno * i % mod
    ret = mol * pow(deno, mod - 2, mod) % mod
    return ret


x, y = list(map(int, input().split()))
if (x + y) % 3 != 0 or 2 * y - x < 0 or 2 * x - y < 0:
    print((0))
else:
    a = (2 * y - x) // 3
    b = (2 * x - y) // 3
    mod = 10**9 + 7
    print((comb(a + b, a, mod)))

-def modinv(a, m): -    return pow(a, m - 2, m) +# nCrをmodで割った余りO(r) +def comb(n, r, mod): +    r = min(r, n - r) +    mol = 1 +    deno = 1 +    for i in range(1, r + 1): +        mol = mol * (n - r + i) % mod +        deno = deno * i % mod +    ret = mol * pow(deno, mod - 2, mod) % mod +    return ret -    ans = 1 -    for i in range(1, a + 1): -        ans = ans * (i + b) * modinv(i, mod) % mod -    print(ans) +    print((comb(a + b, a, mod)))