def decompressish(s):
    """
    returns tuple (X, S) where X is the size of the decompressed parts,
                        and S is the remaining string to decompress
    """
    count = 0
    while s[0] != '(':
        count += 1
        s = s[1:]
        if len(s) == 0:
            return (count, "")

    s = s[1:] # remove initial bracket
    marker = ""
    while s[0] != ')':
        marker += s[0]
        s = s[1:]
    s = s[1:] # remove second bracket

    number_chars_to_repeat, repeat_times = [int(x) for x in marker.split("x")]

    chars_to_repeat = s[:number_chars_to_repeat]
    remaining = s[number_chars_to_repeat:]
    # print(count, chars_to_repeat, repeat_times, remaining)

    return (count + len(chars_to_repeat) * repeat_times, remaining)