def readUVARI(stream):
    """
    Reads a Variable-Length Unsigned Integer from stream

    :type stream: FileIO or BytesIO
    :param stream: Where to read from

    :return: result
    :rtype: int

    """
    b = stream.read(1)[0]
    if b & 128:
        if b & 64:
            b &= 63
            for i in range(3):
                b <<= 8
                b |= stream.read(1)[0]
        else:
            b &= 127
            b <<= 8
            b |= stream.read(1)[0]
    return b
