def read_from(stream) -> int:
    """Reads a compact integer from a stream."""
    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