p = 1000000007



X, Y = list(map(int, input().split()))



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

    print((0))

    exit()



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

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



if a < 0 or b < 0:

    print((0))

    exit()



n = a + b

fac = [0] * (n + 1)

fac[0] = 1

for i in range(n):

    fac[i + 1] = fac[i] * (i + 1) % p





def mcomb(n, k):

    if n == 0 and k == 0:

        return 1

    if n < k or k < 0:

        return 0

    return fac[n] * pow(fac[n - k], p - 2, p) * pow(fac[k], p - 2, p) % p





print((mcomb(n, a)))

# フェルマーの小定理

X, Y = list(map(int, input().split()))



m = 1000000007



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

    print((0))

    exit()



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

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



if a < 0 or b < 0:

    print((0))

    exit()



n = a + b

fac = [0] * (n + 1)

fac[0] = 1

for i in range(n):

    fac[i + 1] = fac[i] * (i + 1) % m





def mcomb(n, k):

    if n == 0 and k == 0:

        return 1

    if n < k or k < 0:

        return 0

    return fac[n] * pow(fac[n - k], m - 2, m) * pow(fac[k], m - 2, m) % m





print((mcomb(n, a)))

p = 1000000007
X, Y = list(map(int, input().split()))
if (X + Y) % 3 != 0:
    print((0))
    exit()
a = (2 * Y - X) // 3
b = (2 * X - Y) // 3
if a < 0 or b < 0:
    print((0))
    exit()
n = a + b
fac = [0] * (n + 1)
fac[0] = 1
for i in range(n):
    fac[i + 1] = fac[i] * (i + 1) % p


def mcomb(n, k):
    if n == 0 and k == 0:
        return 1
    if n < k or k < 0:
        return 0
    return fac[n] * pow(fac[n - k], p - 2, p) * pow(fac[k], p - 2, p) % p


print((mcomb(n, a)))

# フェルマーの小定理
X, Y = list(map(int, input().split()))
m = 1000000007
if (X + Y) % 3 != 0:
    print((0))
    exit()
a = (2 * Y - X) // 3
b = (2 * X - Y) // 3
if a < 0 or b < 0:
    print((0))
    exit()
n = a + b
fac = [0] * (n + 1)
fac[0] = 1
for i in range(n):
    fac[i + 1] = fac[i] * (i + 1) % m


def mcomb(n, k):
    if n == 0 and k == 0:
        return 1
    if n < k or k < 0:
        return 0
    return fac[n] * pow(fac[n - k], m - 2, m) * pow(fac[k], m - 2, m) % m


print((mcomb(n, a)))

-p = 1000000007 +# フェルマーの小定理 +m = 1000000007 -    fac[i + 1] = fac[i] * (i + 1) % p +    fac[i + 1] = fac[i] * (i + 1) % m -    return fac[n] * pow(fac[n - k], p - 2, p) * pow(fac[k], p - 2, p) % p +    return fac[n] * pow(fac[n - k], m - 2, m) * pow(fac[k], m - 2, m) % m