def sq(a, b, mod):  # aのb乗を剰余,kは初期値#20191116-D-Knight

    if b == 0:

        return 1

    elif b % 2 == 0:

        return sq(a, b // 2, mod)**2 % mod

    else:

        return sq(a, b - 1, mod) * a % mod





def nCk(n, k, mod=10**9 + 7):

    x = max(k, n - k)

    y = min(k, n - k)

    kkai = 1

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

        kkai = (kkai * i) % mod

    nkkai = 1

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

        nkkai = (nkkai * i) % mod

    answer = sq(kkai, mod - 2, mod) * nkkai % mod

    return answer





from sys import exit

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

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

    print((0))

    exit()



if X % 2 == 0:

    syurui = X - (X // 2) + 1

else:

    syurui = X - (X // 2)

for i in range(syurui):

    two = i

    one = X - two * 2

    if (two + one * 2) == Y:

        print((nCk(two + one, two)))

        exit()

print((0))

def sq(a, b, mod):  # aのb乗を剰余,kは初期値#20191116-D-Knight

    if b == 0:

        return 1

    elif b % 2 == 0:

        return sq(a, b // 2, mod)**2 % mod

    else:

        return sq(a, b - 1, mod) * a % mod





def nCk(n, k, mod=10 ** 9 + 7):

    x = max(k, n - k)

    y = min(k, n - k)

    kkai = 1

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

        kkai = (kkai * i) % mod

    nkkai = 1

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

        nkkai = (nkkai * i) % mod

    answer = sq(kkai, mod - 2, mod) * nkkai % mod

    return answer





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

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

    print((0))

else:

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

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

    if n < 0 or m < 0:

        print((0))

    else:

        print((nCk(n + m, n)))

def sq(a, b, mod):  # aのb乗を剰余,kは初期値#20191116-D-Knight
    if b == 0:
        return 1
    elif b % 2 == 0:
        return sq(a, b // 2, mod) ** 2 % mod
    else:
        return sq(a, b - 1, mod) * a % mod


def nCk(n, k, mod=10**9 + 7):
    x = max(k, n - k)
    y = min(k, n - k)
    kkai = 1
    for i in range(2, y + 1):
        kkai = (kkai * i) % mod
    nkkai = 1
    for i in range(x + 1, n + 1):
        nkkai = (nkkai * i) % mod
    answer = sq(kkai, mod - 2, mod) * nkkai % mod
    return answer


from sys import exit

X, Y = list(map(int, input().split()))
if (X + Y) % 3 != 0:
    print((0))
    exit()
if X % 2 == 0:
    syurui = X - (X // 2) + 1
else:
    syurui = X - (X // 2)
for i in range(syurui):
    two = i
    one = X - two * 2
    if (two + one * 2) == Y:
        print((nCk(two + one, two)))
        exit()
print((0))

def sq(a, b, mod):  # aのb乗を剰余,kは初期値#20191116-D-Knight
    if b == 0:
        return 1
    elif b % 2 == 0:
        return sq(a, b // 2, mod) ** 2 % mod
    else:
        return sq(a, b - 1, mod) * a % mod


def nCk(n, k, mod=10**9 + 7):
    x = max(k, n - k)
    y = min(k, n - k)
    kkai = 1
    for i in range(2, y + 1):
        kkai = (kkai * i) % mod
    nkkai = 1
    for i in range(x + 1, n + 1):
        nkkai = (nkkai * i) % mod
    answer = sq(kkai, mod - 2, mod) * nkkai % mod
    return answer


X, Y = list(map(int, input().split()))
if (X + Y) % 3 != 0:
    print((0))
else:
    n = (2 * Y - X) // 3
    m = (2 * X - Y) // 3
    if n < 0 or m < 0:
        print((0))
    else:
        print((nCk(n + m, n)))

-from sys import exit - -    exit() -if X % 2 == 0: -    syurui = X - (X // 2) + 1 -    syurui = X - (X // 2) -for i in range(syurui): -    two = i -    one = X - two * 2 -    if (two + one * 2) == Y: -        print((nCk(two + one, two))) -        exit() -print((0)) +    n = (2 * Y - X) // 3 +    m = (2 * X - Y) // 3 +    if n < 0 or m < 0: +        print((0)) +    else: +        print((nCk(n + m, n)))