from typing import Tuple


def decode_length(b: bytes) -> Tuple[int, int]:
    """ Decodes a shortvec-encoded length from the provided bytes

    :param b: The provided bytes
    :return: The length decoded from the provided bytes and how many bytes it used.
    """

    offset = 0
    length = 0

    while offset < len(b):
        val = b[offset]
        length |= (val & 0x7f) << (offset * 7)
        offset += 1

        if (val & 0x80) == 0:
            break

    if offset > 3:
        raise ValueError(f'invalid size: {offset} (max 3)')

    return length, offset