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

mod = 10**9 + 7



if (X + Y) % 3 != 0 or X > 2*Y or Y > 2*X:

    print((0))

else:

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

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

    n = n2x + n1x



    # nCn2xを求める

    def combs(n,n2x):

        invs = [1] * (n+1)

        nfac = 1

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

            nfac = nfac * i % mod

            invs[i] = pow(nfac, mod-2, mod)

        return nfac * invs[n2x] * invs[n-n2x] % mod



    print((combs(n, n2x)))

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

mod = 10**9 + 7



if (X + Y) % 3 != 0 or X > 2*Y or Y > 2*X:

    print((0))

else:

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

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

    n = n2x + n1x



    # nCn2xを求める

    def combs(n,n2x,mod):

        facs = [1] * (n+1)

        # invs = [1] * (n+1)

        nfac = 1

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

            nfac = nfac * i % mod

            facs[i] = nfac

            # invs[i] = pow(nfac, mod-2, mod)

        return nfac * (pow(facs[n2x], mod-2, mod) * pow(facs[n-n2x], mod-2, mod)) % mod



    print((combs(n, n2x, mod)))
X, Y = list(map(int, input().split()))
mod = 10**9 + 7
if (X + Y) % 3 != 0 or X > 2 * Y or Y > 2 * X:
    print((0))
else:
    n2x = (2 * X - Y) // 3
    n1x = (2 * Y - X) // 3
    n = n2x + n1x
    # nCn2xを求める
    def combs(n, n2x):
        invs = [1] * (n + 1)
        nfac = 1
        for i in range(1, n + 1):
            nfac = nfac * i % mod
            invs[i] = pow(nfac, mod - 2, mod)
        return nfac * invs[n2x] * invs[n - n2x] % mod

    print((combs(n, n2x)))

X, Y = list(map(int, input().split()))
mod = 10**9 + 7
if (X + Y) % 3 != 0 or X > 2 * Y or Y > 2 * X:
    print((0))
else:
    n2x = (2 * X - Y) // 3
    n1x = (2 * Y - X) // 3
    n = n2x + n1x
    # nCn2xを求める
    def combs(n, n2x, mod):
        facs = [1] * (n + 1)
        # invs = [1] * (n+1)
        nfac = 1
        for i in range(1, n + 1):
            nfac = nfac * i % mod
            facs[i] = nfac
            # invs[i] = pow(nfac, mod-2, mod)
        return (
            nfac
            * (pow(facs[n2x], mod - 2, mod) * pow(facs[n - n2x], mod - 2, mod))
            % mod
        )

    print((combs(n, n2x, mod)))

-    def combs(n, n2x): -        invs = [1] * (n + 1) +    def combs(n, n2x, mod): +        facs = [1] * (n + 1) +        # invs = [1] * (n+1) -            invs[i] = pow(nfac, mod - 2, mod) -        return nfac * invs[n2x] * invs[n - n2x] % mod +            facs[i] = nfac +            # invs[i] = pow(nfac, mod-2, mod) +        return ( +            nfac +            * (pow(facs[n2x], mod - 2, mod) * pow(facs[n - n2x], mod - 2, mod)) +            % mod +        ) -    print((combs(n, n2x))) +    print((combs(n, n2x, mod)))