import io


def compact_decode(b:bytes) -> int:
    """Converts bytes with compact int to int"""
    stream = io.BytesIO(b)
    i = stream.read(1)[0]
    if i >= 0xfd:
        bytes_to_read = 2**(i-0xfc)
        return int.from_bytes(stream.read(bytes_to_read), 'little')
    else:
        return i