import java.util.Scanner;

/* E->(E+E)
 * E-> int
 */

public class Calc2 {
    
    private static Scanner s;        // tokenizer
    private static int result;       // value of parsed expression
    private static String copy="";   // copy of parsed String
    private static String original;  // original expression
    private static Exp tree;         // expression tree

    public static void main(String[] args) {
	setTokenizer(args);
	parseExp();
	showResult();
	s.close();
    }
    
    private static void setTokenizer(String[] args) {
	try {
	    if(args.length < 1) {
		System.out.println("Usage: Calc2 \"expression to parse\"");
		System.exit(0);
	    }
	    original=args[0];
	    s = new Scanner(args[0]);
	} 
	catch(Exception e) {
	    System.out.println("Error:" + e.getMessage());
	    System.exit(0);
	}
    }

    private static void parseExp() {
	
	tree = new AddExp(s);
	copy = tree.toString();
	result = tree.toValue();
    }

    private static void showResult() {
	System.out.println("Original expression:  " + original);
	System.out.println("Copy of expression:   " + copy);
	System.out.println("Result of expression: " + result);
    }

    
}

abstract class Exp { 
    abstract public int toValue();
}

class AddExp extends Exp {

    private Exp lhs;
    private Exp rhs;

    public AddExp(Scanner s) {
	String token=s.next();
	if (token.equals("(")) {
	    lhs = new AddExp(s);
	    s.next();
	    rhs = new AddExp(s);
	    s.next();
	}
	else {
	    lhs = new IntExp(token);
	    rhs = null;
	}
    }
    
    public String toString() {
	if (rhs==null) return lhs.toString();
	else return "( " + lhs + " + " + rhs + " )";
    }

    public int toValue() {
	int value=0;
	if (lhs!=null) value+=lhs.toValue();
	if (rhs!=null) value+=rhs.toValue();
	return value;
    }
}

class IntExp extends Exp {

    private int i;

    public IntExp(String token) {
	i = Integer.parseInt(token);
    }

    public String toString() {
	return i+"";
    }

    public int toValue() {
	return i;
    }

}
