x, y = [int(i) for i in input().split()]

if (x + y) % 3 != 0:

    print((0))

    exit()

z = (x + y) // 3

x -= z

y -= z



p = 10**9+7





def kai(x, p):

    a = 1

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

        a *= i

        a %= p

    return a





def comb(a, b, p):

    if a < 0 or b < 0:

        return 0

    elif a < b:

        return 0

    c = 1

    c *= kai(a, p)

    c *= pow(kai(b, p), p - 2, p)

    c *= pow(kai(a - b, p), p - 2, p)

    return c % p





print((comb(x+y, x, p)))

x, y = [int(i) for i in input().split()]



def kai(x, p):

    a = 1

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

        a *= i

        a %= p

    return a



def comb(a, b, p):

    if a < 0 or b < 0:

        return 0

    elif a < b:

        return 0

    c = 1

    c *= kai(a, p)

    c *= pow(kai(b, p), p - 2, p)

    c *= pow(kai(a - b, p), p - 2, p)

    return c % p



if (x + y) % 3 != 0:

    print((0))

    exit()



z = (x + y) // 3

p = 10 ** 9 + 7

print((comb(x + y - 2 * z, x - z, p)))

x, y = [int(i) for i in input().split()]
if (x + y) % 3 != 0:
    print((0))
    exit()
z = (x + y) // 3
x -= z
y -= z
p = 10**9 + 7


def kai(x, p):
    a = 1
    for i in range(1, x + 1):
        a *= i
        a %= p
    return a


def comb(a, b, p):
    if a < 0 or b < 0:
        return 0
    elif a < b:
        return 0
    c = 1
    c *= kai(a, p)
    c *= pow(kai(b, p), p - 2, p)
    c *= pow(kai(a - b, p), p - 2, p)
    return c % p


print((comb(x + y, x, p)))

x, y = [int(i) for i in input().split()]


def kai(x, p):
    a = 1
    for i in range(1, x + 1):
        a *= i
        a %= p
    return a


def comb(a, b, p):
    if a < 0 or b < 0:
        return 0
    elif a < b:
        return 0
    c = 1
    c *= kai(a, p)
    c *= pow(kai(b, p), p - 2, p)
    c *= pow(kai(a - b, p), p - 2, p)
    return c % p


if (x + y) % 3 != 0:
    print((0))
    exit()
z = (x + y) // 3
p = 10**9 + 7
print((comb(x + y - 2 * z, x - z, p)))

-if (x + y) % 3 != 0: -    print((0)) -    exit() -z = (x + y) // 3 -x -= z -y -= z -p = 10**9 + 7 -print((comb(x + y, x, p))) +if (x + y) % 3 != 0: +    print((0)) +    exit() +z = (x + y) // 3 +p = 10**9 + 7 +print((comb(x + y - 2 * z, x - z, p)))