import java.util.*;
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		ArrayList<String> expr = new ArrayList<String>();
		while(s.hasNext()){
			expr.add(s.next());
		}

		ArrayList<Integer> buffer = new ArrayList<Integer>();
		Integer left = 0;
		Integer right = 0;
		while(expr.size() > 0){
			if(expr.get(0).equals("+")){
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left + right);
				expr.remove(0);
			}
			else if(expr.get(0).equals("-")){
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left - right);
				expr.remove(0);
			}
			else if(expr.get(0).equals("*")){
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left * right);
				expr.remove(0);
			}
			else{
				buffer.add(toi(expr.remove(0)));
			}
		}
		System.out.println(buffer.get(0));
	}
	private static Integer toi(String b){
		return Integer.parseInt(b);
	}

} import java.util.*; util.* java public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		ArrayList<String> expr = new ArrayList<String>();
		while(s.hasNext()){
			expr.add(s.next());
		}

		ArrayList<Integer> buffer = new ArrayList<Integer>();
		Integer left = 0;
		Integer right = 0;
		while(expr.size() > 0){
			if(expr.get(0).equals("+")){
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left + right);
				expr.remove(0);
			}
			else if(expr.get(0).equals("-")){
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left - right);
				expr.remove(0);
			}
			else if(expr.get(0).equals("*")){
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left * right);
				expr.remove(0);
			}
			else{
				buffer.add(toi(expr.remove(0)));
			}
		}
		System.out.println(buffer.get(0));
	}
	private static Integer toi(String b){
		return Integer.parseInt(b);
	}

} Main /**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		ArrayList<String> expr = new ArrayList<String>();
		while(s.hasNext()){
			expr.add(s.next());
		}

		ArrayList<Integer> buffer = new ArrayList<Integer>();
		Integer left = 0;
		Integer right = 0;
		while(expr.size() > 0){
			if(expr.get(0).equals("+")){
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left + right);
				expr.remove(0);
			}
			else if(expr.get(0).equals("-")){
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left - right);
				expr.remove(0);
			}
			else if(expr.get(0).equals("*")){
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left * right);
				expr.remove(0);
			}
			else{
				buffer.add(toi(expr.remove(0)));
			}
		}
		System.out.println(buffer.get(0));
	} main {
		Scanner s = new Scanner(System.in);
		ArrayList<String> expr = new ArrayList<String>();
		while(s.hasNext()){
			expr.add(s.next());
		}

		ArrayList<Integer> buffer = new ArrayList<Integer>();
		Integer left = 0;
		Integer right = 0;
		while(expr.size() > 0){
			if(expr.get(0).equals("+")){
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left + right);
				expr.remove(0);
			}
			else if(expr.get(0).equals("-")){
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left - right);
				expr.remove(0);
			}
			else if(expr.get(0).equals("*")){
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left * right);
				expr.remove(0);
			}
			else{
				buffer.add(toi(expr.remove(0)));
			}
		}
		System.out.println(buffer.get(0));
	} Scanner s = new Scanner(System.in); s new Scanner(System.in) ArrayList<String> expr = new ArrayList<String>(); expr new ArrayList<String>() while(s.hasNext()){
			expr.add(s.next());
		} s.hasNext() s.hasNext s {
			expr.add(s.next());
		} expr.add(s.next()) expr.add expr s.next() s.next s ArrayList<Integer> buffer = new ArrayList<Integer>(); buffer new ArrayList<Integer>() Integer left = 0; left 0 Integer right = 0; right 0 while(expr.size() > 0){
			if(expr.get(0).equals("+")){
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left + right);
				expr.remove(0);
			}
			else if(expr.get(0).equals("-")){
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left - right);
				expr.remove(0);
			}
			else if(expr.get(0).equals("*")){
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left * right);
				expr.remove(0);
			}
			else{
				buffer.add(toi(expr.remove(0)));
			}
		} expr.size() > 0 expr.size() expr.size expr 0 {
			if(expr.get(0).equals("+")){
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left + right);
				expr.remove(0);
			}
			else if(expr.get(0).equals("-")){
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left - right);
				expr.remove(0);
			}
			else if(expr.get(0).equals("*")){
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left * right);
				expr.remove(0);
			}
			else{
				buffer.add(toi(expr.remove(0)));
			}
		} if(expr.get(0).equals("+")){
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left + right);
				expr.remove(0);
			}
			else if(expr.get(0).equals("-")){
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left - right);
				expr.remove(0);
			}
			else if(expr.get(0).equals("*")){
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left * right);
				expr.remove(0);
			}
			else{
				buffer.add(toi(expr.remove(0)));
			} expr.get(0).equals("+") expr.get(0).equals expr.get(0) expr.get expr 0 "+" {
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left + right);
				expr.remove(0);
			} right = buffer.remove(buffer.size() - 1) right buffer.remove(buffer.size() - 1) buffer.remove buffer buffer.size() - 1 buffer.size() buffer.size buffer 1 left = buffer.remove(buffer.size() - 1) left buffer.remove(buffer.size() - 1) buffer.remove buffer buffer.size() - 1 buffer.size() buffer.size buffer 1 buffer.add(left + right) buffer.add buffer left + right left right expr.remove(0) expr.remove expr 0 if(expr.get(0).equals("-")){
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left - right);
				expr.remove(0);
			}
			else if(expr.get(0).equals("*")){
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left * right);
				expr.remove(0);
			}
			else{
				buffer.add(toi(expr.remove(0)));
			} expr.get(0).equals("-") expr.get(0).equals expr.get(0) expr.get expr 0 "-" {
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left - right);
				expr.remove(0);
			} right = buffer.remove(buffer.size() - 1) right buffer.remove(buffer.size() - 1) buffer.remove buffer buffer.size() - 1 buffer.size() buffer.size buffer 1 left = buffer.remove(buffer.size() - 1) left buffer.remove(buffer.size() - 1) buffer.remove buffer buffer.size() - 1 buffer.size() buffer.size buffer 1 buffer.add(left - right) buffer.add buffer left - right left right expr.remove(0) expr.remove expr 0 if(expr.get(0).equals("*")){
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left * right);
				expr.remove(0);
			}
			else{
				buffer.add(toi(expr.remove(0)));
			} expr.get(0).equals("*") expr.get(0).equals expr.get(0) expr.get expr 0 "*" {
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left * right);
				expr.remove(0);
			} right = buffer.remove(buffer.size() - 1) right buffer.remove(buffer.size() - 1) buffer.remove buffer buffer.size() - 1 buffer.size() buffer.size buffer 1 left = buffer.remove(buffer.size() - 1) left buffer.remove(buffer.size() - 1) buffer.remove buffer buffer.size() - 1 buffer.size() buffer.size buffer 1 buffer.add(left * right) buffer.add buffer left * right left right expr.remove(0) expr.remove expr 0 {
				buffer.add(toi(expr.remove(0)));
			} buffer.add(toi(expr.remove(0))) buffer.add buffer toi(expr.remove(0)) toi expr.remove(0) expr.remove expr 0 System.out.println(buffer.get(0)) System.out.println System.out System System.out buffer.get(0) buffer.get buffer 0 String[] args args private static Integer toi(String b){
		return Integer.parseInt(b);
	} toi {
		return Integer.parseInt(b);
	} return Integer.parseInt(b); Integer.parseInt(b) Integer.parseInt Integer b String b b public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		ArrayList<String> expr = new ArrayList<String>();
		while(s.hasNext()){
			expr.add(s.next());
		}

		ArrayList<Integer> buffer = new ArrayList<Integer>();
		Integer left = 0;
		Integer right = 0;
		while(expr.size() > 0){
			if(expr.get(0).equals("+")){
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left + right);
				expr.remove(0);
			}
			else if(expr.get(0).equals("-")){
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left - right);
				expr.remove(0);
			}
			else if(expr.get(0).equals("*")){
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left * right);
				expr.remove(0);
			}
			else{
				buffer.add(toi(expr.remove(0)));
			}
		}
		System.out.println(buffer.get(0));
	}
	private static Integer toi(String b){
		return Integer.parseInt(b);
	}

} public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		ArrayList<String> expr = new ArrayList<String>();
		while(s.hasNext()){
			expr.add(s.next());
		}

		ArrayList<Integer> buffer = new ArrayList<Integer>();
		Integer left = 0;
		Integer right = 0;
		while(expr.size() > 0){
			if(expr.get(0).equals("+")){
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left + right);
				expr.remove(0);
			}
			else if(expr.get(0).equals("-")){
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left - right);
				expr.remove(0);
			}
			else if(expr.get(0).equals("*")){
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left * right);
				expr.remove(0);
			}
			else{
				buffer.add(toi(expr.remove(0)));
			}
		}
		System.out.println(buffer.get(0));
	}
	private static Integer toi(String b){
		return Integer.parseInt(b);
	}

} Main
import java.util.*;
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		ArrayList<String> expr = new ArrayList<String>();
		while(s.hasNext()){
			expr.add(s.next());
		}

		ArrayList<Integer> buffer = new ArrayList<Integer>();
		Integer left = 0;
		Integer right = 0;
		while(expr.size() > 0){
			if(expr.get(0).equals("+")){
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left + right);
				expr.remove(0);
			}
			else if(expr.get(0).equals("-")){
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left - right);
				expr.remove(0);
			}
			else if(expr.get(0).equals("*")){
				right = buffer.remove(buffer.size() - 1);
				left = buffer.remove(buffer.size() - 1);

				buffer.add(left * right);
				expr.remove(0);
			}
			else{
				buffer.add(toi(expr.remove(0)));
			}
		}
		System.out.println(buffer.get(0));
	}
	private static Integer toi(String b){
		return Integer.parseInt(b);
	}

}