#!/usr/bin/python
import sys

def replace(f, binop):
    binopIndex = f.find(" " + binop + " ")
    if binopIndex < 0:
        return None
    binopIndex += 1
    summ = 0
    i = binopIndex + 1
    while True:
        if i == len(f):
            break
        if summ < 0:
            break
        if f[i] == "(":
            summ += 1
        if f[i] == ")":
            summ -= 1
        i += 1


    j = binopIndex - 1
    summ = 0
    while True:
        if j == -1:
            break
        if summ > 0:
            break
        if f[j] == "(":
            summ += 1
        if f[j] == ")":
            summ -= 1
        j -= 1

    original = f[j+1:i]
    substitute = f[j+1:i]
#    substitute = binop + substitute.replace(" " + binop, ",")
    substitute = substitute[:(binopIndex - j) - 1] + "," + substitute[binopIndex - j:]
    substitute = "(%s)" % (binop + substitute)
#    print "%s -->> %s" % (original, substitute)
    return f.replace(original, substitute)


def main():
    binops = ["U", "R"]
 
    for ff in sys.stdin.readlines():
        f = ff[:-1]
        while True:
            changed = False
            for binop in binops:
                newF = replace(f, binop)
                if not newF == None:
                    f = newF 
                    changed = True

            if not changed:
                break
        print f
         

if __name__ == '__main__':
    main()
