import java.awt.*;

public class Main {
	public static void main(String[] args) {
		PileChainee<String> pile = new PileChainee<>();

		for (int i = 0; i != args.length; i++) {
			try {
				Integer.parseInt(args[i]);
				pile.addFirst(args[i]);
			} catch (NumberFormatException e) {
				int n2 = Integer.parseInt(pile.removeFirst());
				int n1 = Integer.parseInt(pile.removeFirst());
				System.out.println(n2);
				System.out.println(n1);

				switch (args[i]) {
					case "+":
						pile.addFirst(n1 + n2 + "");
						break;
					case "-":
						pile.addFirst(n1 - n2 + "");
						break;
					case "x":
						pile.addFirst(n1 * n2 + "");
						break;
					case "/":
						pile.addFirst(n1 / n2 + "");
				}
			}
		}

		System.out.println("= " + pile.removeFirst());


	}
}