def make_tables(m):

    fac=[1,1]

    finv=[1,1]

    inv=[0,1]

    for i in range(2,m+1):

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

        inv.append((-inv[mod%i]*(mod//i))%mod)

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

    return fac,finv



def calc_nCk(n,k,fac,finv):

    if n<k or (n<0 or k<0):

        return 0

#    k=min(k,n-k)

    return fac[n]*(finv[k]*finv[n-k]%mod)%mod



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

mod=10**9+7

n=(y-0.5*x)/1.5

if int(n)!=n:

    print((0))

else:

    m=(y+x)//3

    l=int(n)

    fac,finv=make_tables(m)

    ans = calc_nCk(m,l,fac,finv)

    print(ans)
def nCk(n,k):

    if n<k or (n<0 or k<0):

        return 0

    #k=min(k,n-k)

    num,denum=1,1

    for i in range(k):

        num=num*(n-i)%mod

        denum=denum*(i+1)%mod

    return num*pow(denum,mod-2,mod)%mod



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

mod=10**9+7

n=(y-0.5*x)/1.5

if int(n)!=n:

    print((0))

else:

    m=(y+x)//3

    l=int(n)

    print((nCk(m,l)))
def make_tables(m):
    fac = [1, 1]
    finv = [1, 1]
    inv = [0, 1]
    for i in range(2, m + 1):
        fac.append((fac[-1] * i) % mod)
        inv.append((-inv[mod % i] * (mod // i)) % mod)
        finv.append(finv[i - 1] * inv[i] % mod)
    return fac, finv


def calc_nCk(n, k, fac, finv):
    if n < k or (n < 0 or k < 0):
        return 0
    #    k=min(k,n-k)
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod


x, y = list(map(int, input().split()))
mod = 10**9 + 7
n = (y - 0.5 * x) / 1.5
if int(n) != n:
    print((0))
else:
    m = (y + x) // 3
    l = int(n)
    fac, finv = make_tables(m)
    ans = calc_nCk(m, l, fac, finv)
    print(ans)

def nCk(n, k):
    if n < k or (n < 0 or k < 0):
        return 0
    # k=min(k,n-k)
    num, denum = 1, 1
    for i in range(k):
        num = num * (n - i) % mod
        denum = denum * (i + 1) % mod
    return num * pow(denum, mod - 2, mod) % mod


x, y = list(map(int, input().split()))
mod = 10**9 + 7
n = (y - 0.5 * x) / 1.5
if int(n) != n:
    print((0))
else:
    m = (y + x) // 3
    l = int(n)
    print((nCk(m, l)))

-def make_tables(m): -    fac = [1, 1] -    finv = [1, 1] -    inv = [0, 1] -    for i in range(2, m + 1): -        fac.append((fac[-1] * i) % mod) -        inv.append((-inv[mod % i] * (mod // i)) % mod) -        finv.append(finv[i - 1] * inv[i] % mod) -    return fac, finv - - -def calc_nCk(n, k, fac, finv): +def nCk(n, k): -    #    k=min(k,n-k) -    return fac[n] * (finv[k] * finv[n - k] % mod) % mod +    # k=min(k,n-k) +    num, denum = 1, 1 +    for i in range(k): +        num = num * (n - i) % mod +        denum = denum * (i + 1) % mod +    return num * pow(denum, mod - 2, mod) % mod -    fac, finv = make_tables(m) -    ans = calc_nCk(m, l, fac, finv) -    print(ans) +    print((nCk(m, l)))