def knight(x, y):

    mod = 10 ** 9 + 7

    x, y = min(x, y), max(x, y)



    if (x + y) % 3 != 0:

        return 0

    if y > 2 * x:

        return 0



    move = (x + y) // 3

    right = 2 * move - y

    up = move-right



    ans = 1

    for i in range(up):

        ans *= (move - i)

        ans *= pow(i + 1, mod - 2, mod)

        ans %= mod



    return ans





if __name__ == "__main__":

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

    ans = knight(x, y)

    print(ans)

def knight(x, y):

    mod = 10 ** 9 + 7

    x, y = min(x, y), max(x, y)



    if (x + y) % 3 != 0:

        return 0

    if y > 2 * x:

        return 0



    move = (x + y) // 3

    right = 2 * move - y

    up = move-right



    ans = 1

    tmp = 1

    for i in range(up):

        ans *= (move - i)

        tmp *= i + 1

        ans %= mod

        tmp %= mod

    ans *= pow(tmp, mod - 2, mod)

    return ans % mod





if __name__ == "__main__":

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

    ans = knight(x, y)

    print(ans)

def knight(x, y):
    mod = 10**9 + 7
    x, y = min(x, y), max(x, y)
    if (x + y) % 3 != 0:
        return 0
    if y > 2 * x:
        return 0
    move = (x + y) // 3
    right = 2 * move - y
    up = move - right
    ans = 1
    for i in range(up):
        ans *= move - i
        ans *= pow(i + 1, mod - 2, mod)
        ans %= mod
    return ans


if __name__ == "__main__":
    x, y = list(map(int, input().split()))
    ans = knight(x, y)
    print(ans)

def knight(x, y):
    mod = 10**9 + 7
    x, y = min(x, y), max(x, y)
    if (x + y) % 3 != 0:
        return 0
    if y > 2 * x:
        return 0
    move = (x + y) // 3
    right = 2 * move - y
    up = move - right
    ans = 1
    tmp = 1
    for i in range(up):
        ans *= move - i
        tmp *= i + 1
        ans %= mod
        tmp %= mod
    ans *= pow(tmp, mod - 2, mod)
    return ans % mod


if __name__ == "__main__":
    x, y = list(map(int, input().split()))
    ans = knight(x, y)
    print(ans)

+    tmp = 1 -        ans *= pow(i + 1, mod - 2, mod) +        tmp *= i + 1 -    return ans +        tmp %= mod +    ans *= pow(tmp, mod - 2, mod) +    return ans % mod