import java.util.* ;
import java.io.* ;

class Exp {
  final static int INT=0, ADD=1, SUB=2, MUL=3, DIV=4 ;
  int tag ;
  // Utilisé si tag == INT
  int asInt ;
  // Utilisés si tag $\in$ {ADD, SUB, MUL, DIV}
  Exp e1, e2 ;

  Exp(int i) { tag = INT ; asInt = i ; }

  Exp(Exp e1, int op, Exp e2) {
    tag = op ; this.e1 = e1 ; this.e2 = e2 ;
  }

  static Exp mkInt(int i) { return new Exp (i) ; }

  static Exp add(Exp e1, Exp e2) { return new Exp (e1, ADD, e2) ; }

  static Exp sub(Exp e1, Exp e2) { return new Exp (e1, SUB, e2) ; }

  static Exp mul(Exp e1, Exp e2) { return new Exp (e1, MUL, e2) ; }

  static Exp div(Exp e1, Exp e2) { return new Exp (e1, DIV, e2) ; }

  static int calc(Exp e) {
    switch (e.tag) {
    case INT: return e.asInt ;
    case ADD: return calc(e.e1) + calc(e.e2) ;
    case SUB: return calc(e.e1) - calc(e.e2) ;
    case MUL: return calc(e.e1) * calc(e.e2) ;
    case DIV: return calc(e.e1) / calc(e.e2) ;
    }
    throw new Error ("calc : arbre Exp incorrect") ;
  }


  static Exp postfixToExp(String [] arg) {
    Stack<Exp> stack = new Stack<Exp> () ;
    for (int k = 0 ; k < arg.length ; k++) {
      Exp e1, e2 ;
      String cmd = arg[k] ;
      if (cmd.equals("+")) {
        e2 = stack.pop() ; e1 = stack.pop() ;
        stack.push(add(e1,e2)) ;
      } else if (cmd.equals("-")) {
        e2 = stack.pop() ; e1 = stack.pop() ;
        stack.push(sub(e1,e2)) ;
      } else if (cmd.equals("*")) {
        e2 = stack.pop() ; e1 = stack.pop() ;
        stack.push(mul(e1,e2)) ;
      } else if (cmd.equals("/")) {
        e2 = stack.pop() ; e1 = stack.pop() ;
        stack.push(div(e1,e2)) ;   
      } else {
        stack.push(mkInt(Integer.parseInt(arg[k]))) ;
      }
      System.err.println(cmd + " -> " + stack) ;
    }
    return stack.pop() ;
  }

  static void expToInfix(PrintWriter out, Exp e, int lvl) {
    switch (e.tag) {
    case INT:
      out.print(e.asInt) ; return ;
    case ADD: case SUB:
      if (lvl > 1) out.print('(') ;
      expToInfix(out, e.e1, 1) ;
      out.print(e.tag == ADD ? '+' : '-') ;
      expToInfix(out, e.e2, 2) ;
      if (lvl > 1) out.print(')') ;
      return ;
    case MUL: case DIV:
      if (lvl > 2) out.print('(') ;
      expToInfix(out, e.e1, 2) ;
      out.print(e.tag == MUL ? '*' : '/') ;
      expToInfix(out, e.e2, 3) ;
      if (lvl > 2) out.print(')') ;
      return ;
    }
    throw new Error ("expToInfix : arbre Exp incorrect") ;
  }

  /* toString astucieux, qui fabrique un
     PrintWriter qui écrit dans un StringWriter,
     afin de récupérer la méthode expToInfix. */
  public String toString() {
    StringWriter sw = new StringWriter () ;
    PrintWriter out = new PrintWriter (sw) ;
    expToInfix(out, this, 1) ;
    out.close() ;
    return sw.toString() ;
  }

  public static void main (String [] arg) {
    PrintWriter out = new PrintWriter (System.out) ;
    Exp e = postfixToExp(arg) ;
    expToInfix(out, e, 1) ;
    out.println() ;
    out.flush() ;
  }

}
