import java.util.*;

public class Main {


      public static BinaryNode convertToTree(String s) {
          Stack<BinaryNode> exprStack = new Stack<>();
          for (int i = 0; i < s.length(); i++) {
              char c = s.charAt(i);
              if (Character.isDigit(c) || isVariable(c)) {
                  exprStack.push(new BinaryNode(c, null, null));
              } else if (isOperator(c)) {
                  if (exprStack.size() < 2) return null;
                  BinaryNode right = exprStack.pop();
                  BinaryNode left = exprStack.pop();
                  exprStack.push(new BinaryNode(c, left, right));
              } else {
                  return null;
              }
          }
          return exprStack.size() == 1 ? exprStack.pop() : null;
      }

      public static void printTree(BinaryNode T) {
          if (T != null) {
              if (isOperand(T)) {
                  System.out.print(T.getD());
              } else {
                  System.out.print("(");
                  printTree(T.getL());
                  System.out.print(" " + T.getD() + " ");
                  printTree(T.getR());
                  System.out.print(")");
              }
          }
      }

      public static BinaryNode Diff(BinaryNode T) {
          if (T == null) return null;
          if (Character.isDigit(T.getD())) {
              return new BinaryNode('0', null, null);
          } else if (isVariable(T.getD())) {
              return new BinaryNode('1', null, null);
          } else {
              BinaryNode leftDiff = Diff(T.getL());
              BinaryNode rightDiff = Diff(T.getR());
              switch (T.getD()) {
                  case '+':
                      return new BinaryNode('+', leftDiff, rightDiff);
                  case '-':
                      return new BinaryNode('-', leftDiff, rightDiff);
                  case '*':
                      BinaryNode prod1 = new BinaryNode('*', T.getL(), rightDiff);
                      BinaryNode prod2 = new BinaryNode('*', rightDiff, T.getL());
                      return new BinaryNode('+', prod1, prod2);
                  // Add cases for other operators as needed
              }
          }
          return null;
      }

      public static BinaryNode simplify(BinaryNode T) {
          if (T == null) return null;
          if (isOperator(T.getD())) {
              BinaryNode left = simplify(T.getL());
              BinaryNode right = simplify(T.getR());
          }
          return T; // If it's not an operator, no simplification needed.
      }

      private static boolean isOperator(char c) {
          return c == '+' || c == '-' || c == '*' || c == '/';
      }

      private static boolean isVariable(char c) {
          return c == 'x';
      }

      private static boolean isOperand(BinaryNode node) {
          return (node != null) && (node.getL() == null) && (node.getR() == null);
      }
  }


  public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    String s = input.nextLine();
    System.out.println("Input string: " + s);
    BinaryNode d = Diff(convertToTree(s));
    System.out.print("Output string: ");
    printTree(d);
    System.out.println();
  }

}