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

public class Eval {
    public static void main(String[] args) throws Exception {

	Hashtable env;	
	env = new Hashtable(); 

	BufferedReader b = new BufferedReader(new InputStreamReader(System.in)); 
	System.out.print("Eval> "); 
	String line = b.readLine(); 

	while (! line.equals("bye")) {

	    StringTokenizer st = new StringTokenizer(line); 

	    String name = null; 

	    Vector v = new Vector();
            int howMany = st.countTokens(); 
	    for (int i = 0; i < howMany; i++) 
		v.addElement(st.nextToken());  

	    if ( v.size() > 2 && ((String) (v.elementAt(1))).equals("=")) {
              name = (String) (v.elementAt(0));  
	      v.removeElementAt(1);
	      v.removeElementAt(0);
            }

	    for (int i = 0; i < v.size(); i++) {
	      String element = (String) (v.elementAt(i)); 
	      if (env.get(element) != null) {
                v.setElementAt((String)(env.get(element)), i); 
	      }
	    }

            boolean done;  

	    do {

	      done = true; 
	      
	      done = done && Eval.removeParens(v);
	      
	      done = done && Eval.removeStars(v);
	      
	      done = done && Eval.removePluses(v);
	      
	      System.out.println("Inside the loop."); 
	      
	    } while (! done); 

	    if (name != null) {
	      env.put(name, (String)(v.elementAt(0))); 
	    }

	    // System.out.println("Outside now."); 

            Eval.print(v);
	    System.out.print("Eval> "); 
	    line = b.readLine(); 	    
	}
	
    }

    static void print (Vector vector) {
	for (int i = 0; i < vector.size(); i++) 
	    System.out.print("[" + vector.elementAt(i) + "]"); 
	System.out.println(); 
    }

    static boolean removeParens(Vector v) { return true; }
    static boolean removeStars (Vector v) { return true; }
    static boolean removePluses(Vector v) { 
        boolean done = true;
	for (int i = 0; i < v.size(); i++) {

	    String a = (String) (v.elementAt(i)); 

	    if (a.equals("+")) {  
		done = false;  
		
		// System.out.println("Plus found at position " + i); 

		String one = (String) (v.elementAt(i - 1));
		String two = (String) (v.elementAt(i + 1));

		int n1 = Integer.parseInt(one), 
		    n2 = Integer.parseInt(two); 

		int res = n1 + n2; 

		System.out.println(res); 

		v.setElementAt(res + "", i - 1); 
		// Eval.print(v);
		v.removeElementAt(i + 1); 
		// Eval.print(v);
		v.removeElementAt(i); 
		// Eval.print(v);

		i = i - 1;

            }
	}
        return done; 
    }

}