mod = int(1e9 + 7)

def powmod(a, b):

    ans = 1

    while(b):

        if(b&1): ans = ans*a%mod

        a = a*a%mod

        b >>= 1

    return ans

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

if(2*x < y or 2*y < x or (2*x-y)%3 or (2*y-x)%3): print((0))

else:

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

    #print(x,y)

    fac = [0 for i in range(x+y+1)]

    inv = [0 for i in range(x+y+1)]

    fac[0] = 1

    for i in range(1,x+y+1):

        fac[i] = fac[i-1]*i%mod

    inv[x+y] = powmod(fac[x+y],mod-2)

    for i in range(x+y-1,-1,-1):

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

    ans = fac[x+y]*inv[x]*inv[y]%mod

    print(ans)
mod = int(1e9 + 7)

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

if(2*x < y or 2*y < x or (2*x-y)%3 or (2*y-x)%3): print((0))

else:

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

    #print(x,y)

    fac = [0 for i in range(x+y+1)]

    fac[0] = 1

    for i in range(1,x+y+1):

        fac[i] = fac[i-1]*i%mod

    ans = fac[x+y]*pow(fac[x],mod-2,mod)*pow(fac[y],mod-2,mod)%mod

    print(ans)
mod = int(1e9 + 7)


def powmod(a, b):
    ans = 1
    while b:
        if b & 1:
            ans = ans * a % mod
        a = a * a % mod
        b >>= 1
    return ans


x, y = list(map(int, input().split()))
if 2 * x < y or 2 * y < x or (2 * x - y) % 3 or (2 * y - x) % 3:
    print((0))
else:
    x, y = (2 * x - y) // 3, (2 * y - x) // 3
    # print(x,y)
    fac = [0 for i in range(x + y + 1)]
    inv = [0 for i in range(x + y + 1)]
    fac[0] = 1
    for i in range(1, x + y + 1):
        fac[i] = fac[i - 1] * i % mod
    inv[x + y] = powmod(fac[x + y], mod - 2)
    for i in range(x + y - 1, -1, -1):
        inv[i] = inv[i + 1] * (i + 1) % mod
    ans = fac[x + y] * inv[x] * inv[y] % mod
    print(ans)

mod = int(1e9 + 7)
x, y = list(map(int, input().split()))
if 2 * x < y or 2 * y < x or (2 * x - y) % 3 or (2 * y - x) % 3:
    print((0))
else:
    x, y = (2 * x - y) // 3, (2 * y - x) // 3
    # print(x,y)
    fac = [0 for i in range(x + y + 1)]
    fac[0] = 1
    for i in range(1, x + y + 1):
        fac[i] = fac[i - 1] * i % mod
    ans = fac[x + y] * pow(fac[x], mod - 2, mod) * pow(fac[y], mod - 2, mod) % mod
    print(ans)

- - -def powmod(a, b): -    ans = 1 -    while b: -        if b & 1: -            ans = ans * a % mod -        a = a * a % mod -        b >>= 1 -    return ans - - -    inv = [0 for i in range(x + y + 1)] -    inv[x + y] = powmod(fac[x + y], mod - 2) -    for i in range(x + y - 1, -1, -1): -        inv[i] = inv[i + 1] * (i + 1) % mod -    ans = fac[x + y] * inv[x] * inv[y] % mod +    ans = fac[x + y] * pow(fac[x], mod - 2, mod) * pow(fac[y], mod - 2, mod) % mod