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

mod = 10**9+7



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

    print((0))

else:

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

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

    '''

    n*(1,2) + m*(2,1) = (x, y)

    x = n+2m

    y = 2n+m

    2x = 2n+4m

    2x-y = 3m

    m = (2x-y)/3

    n = (2y-x)/3 

    '''

    if 0 > n or 0 > m:

        print((0))

    else:

        ans = 1

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

            ans *= (n+m+1-i)*pow(i,mod-2,mod)

            ans %= mod

        print(ans)

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



m, r = divmod(2*Y-X, 3)

if r != 0:

    print((0))

    exit()



n = Y - 2*m



if n < 0 or m < 0:

    print((0))

    exit()



def modinv(a, mod=10**9+7):

    return pow(a, mod-2, mod)



def combination(n, r, mod=10**9+7):

    r = min(r, n-r)

    res = 1

    for i in range(r):

        res = res * (n-i) * modinv(i+1, mod) % mod

    return res



print((combination(n+m, n)))
X, Y = list(map(int, input().split()))
mod = 10**9 + 7
if (X + Y) % 3 != 0:
    print((0))
else:
    n = (2 * Y - X) // 3
    m = (2 * X - Y) // 3
    """
    n*(1,2) + m*(2,1) = (x, y)
    x = n+2m
    y = 2n+m
    2x = 2n+4m
    2x-y = 3m
    m = (2x-y)/3
    n = (2y-x)/3 
    """
    if 0 > n or 0 > m:
        print((0))
    else:
        ans = 1
        for i in range(1, n + 1):
            ans *= (n + m + 1 - i) * pow(i, mod - 2, mod)
            ans %= mod
        print(ans)

X, Y = list(map(int, input().split()))
m, r = divmod(2 * Y - X, 3)
if r != 0:
    print((0))
    exit()
n = Y - 2 * m
if n < 0 or m < 0:
    print((0))
    exit()


def modinv(a, mod=10**9 + 7):
    return pow(a, mod - 2, mod)


def combination(n, r, mod=10**9 + 7):
    r = min(r, n - r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i + 1, mod) % mod
    return res


print((combination(n + m, n)))

-mod = 10**9 + 7 -if (X + Y) % 3 != 0: +m, r = divmod(2 * Y - X, 3) +if r != 0: -else: -    n = (2 * Y - X) // 3 -    m = (2 * X - Y) // 3 -    """ -    n*(1,2) + m*(2,1) = (x, y) -    x = n+2m -    y = 2n+m -    2x = 2n+4m -    2x-y = 3m -    m = (2x-y)/3 -    n = (2y-x)/3 -    """ -    if 0 > n or 0 > m: -        print((0)) -    else: -        ans = 1 -        for i in range(1, n + 1): -            ans *= (n + m + 1 - i) * pow(i, mod - 2, mod) -            ans %= mod -        print(ans) +    exit() +n = Y - 2 * m +if n < 0 or m < 0: +    print((0)) +    exit() + + +def modinv(a, mod=10**9 + 7): +    return pow(a, mod - 2, mod) + + +def combination(n, r, mod=10**9 + 7): +    r = min(r, n - r) +    res = 1 +    for i in range(r): +        res = res * (n - i) * modinv(i + 1, mod) % mod +    return res + + +print((combination(n + m, n)))