#D

def main():

    mod=1000000007

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

    k=min(x,y//2)

    l=min(x//2,y)

    n=k+l

    

    Fact=[1]

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

        Fact.append(Fact[i-1]*i%mod)

    Finv=[0]*(n+1) #階乗の逆元

    Finv[-1]=pow(Fact[-1],mod-2,mod)

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

        Finv[i]=Finv[i+1]*(i+1)%mod

    def comb(n,r):

        if n<r:

            return 0

        return Fact[n]*Finv[r]*Finv[n-r]%mod

    

    ans=0

    for a in range(k+1):

        if (x-a)%2!=0:

            continue

        if (x-a)//2==y-2*a:

            b=(x-a)//2

            ans+=comb(a+b,a)

            ans%=mod

    print(ans)

    

if __name__=='__main__':

    main()
def main():

    mod=1000000007

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

    if (x+y)%3:

        return 0

    

    n=(x+y)//3

    Fact=[1]

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

        Fact.append(Fact[i-1]*i%mod)

    Finv=[0]*(n+1)

    Finv[-1]=pow(Fact[-1],mod-2,mod)

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

        Finv[i]=Finv[i+1]*(i+1)%mod

    def comb(n,r):

        if n<r:

            return 0

        return Fact[n]*Finv[r]*Finv[n-r]%mod

    

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

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

    if a<0 or b<0:

        return 0

    return comb(a+b,a)

    

if __name__=='__main__':

    print((main()))
# D
def main():
    mod = 1000000007
    x, y = list(map(int, input().split()))
    k = min(x, y // 2)
    l = min(x // 2, y)
    n = k + l
    Fact = [1]
    for i in range(1, n + 1):
        Fact.append(Fact[i - 1] * i % mod)
    Finv = [0] * (n + 1)  # 階乗の逆元
    Finv[-1] = pow(Fact[-1], mod - 2, mod)
    for i in range(n - 1, -1, -1):
        Finv[i] = Finv[i + 1] * (i + 1) % mod

    def comb(n, r):
        if n < r:
            return 0
        return Fact[n] * Finv[r] * Finv[n - r] % mod

    ans = 0
    for a in range(k + 1):
        if (x - a) % 2 != 0:
            continue
        if (x - a) // 2 == y - 2 * a:
            b = (x - a) // 2
            ans += comb(a + b, a)
            ans %= mod
    print(ans)


if __name__ == "__main__":
    main()

def main():
    mod = 1000000007
    x, y = list(map(int, input().split()))
    if (x + y) % 3:
        return 0
    n = (x + y) // 3
    Fact = [1]
    for i in range(1, n + 1):
        Fact.append(Fact[i - 1] * i % mod)
    Finv = [0] * (n + 1)
    Finv[-1] = pow(Fact[-1], mod - 2, mod)
    for i in range(n - 1, -1, -1):
        Finv[i] = Finv[i + 1] * (i + 1) % mod

    def comb(n, r):
        if n < r:
            return 0
        return Fact[n] * Finv[r] * Finv[n - r] % mod

    a = (-x + 2 * y) // 3
    b = (x * 2 - y) // 3
    if a < 0 or b < 0:
        return 0
    return comb(a + b, a)


if __name__ == "__main__":
    print((main()))

-# D -    k = min(x, y // 2) -    l = min(x // 2, y) -    n = k + l +    if (x + y) % 3: +        return 0 +    n = (x + y) // 3 -    Finv = [0] * (n + 1)  # 階乗の逆元 +    Finv = [0] * (n + 1) -    ans = 0 -    for a in range(k + 1): -        if (x - a) % 2 != 0: -            continue -        if (x - a) // 2 == y - 2 * a: -            b = (x - a) // 2 -            ans += comb(a + b, a) -            ans %= mod -    print(ans) +    a = (-x + 2 * y) // 3 +    b = (x * 2 - y) // 3 +    if a < 0 or b < 0: +        return 0 +    return comb(a + b, a) -    main() +    print((main()))