import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Main {

	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		Stack<Integer>stk=new Stack<>();
		
		while(cin.hasNext()) {
			String obj=cin.next();
			
			Pattern p=Pattern.compile("^[0-9]*$");
			Matcher m=p.matcher(obj);
			if(m.find()) {
				stk.push(Integer.valueOf(obj));
			}
			else {
				if(obj.equals("+")) {
					int sum=0;
					for(int i=0;i<2;i++) {
						sum+=stk.peek();
						stk.pop();
					}
					stk.push(sum);
				}
				else if(obj.equals("-")) {
					int sum=stk.peek();stk.pop();
					sum=stk.peek()-sum;stk.pop();
					stk.push(sum);
				}
				else if(obj.equals("*")) {
					int sum=1;
					for(int i=0;i<2;i++) {
						sum*=stk.peek();
						stk.pop();
					}
					stk.push(sum);
				}
			}
			
		}
		System.out.println(stk.peek());
		
	}

}
 import java.util.*; util.* java import java.util.regex.Matcher; Matcher java.util.regex import java.util.regex.Pattern; Pattern java.util.regex public class Main {

	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		Stack<Integer>stk=new Stack<>();
		
		while(cin.hasNext()) {
			String obj=cin.next();
			
			Pattern p=Pattern.compile("^[0-9]*$");
			Matcher m=p.matcher(obj);
			if(m.find()) {
				stk.push(Integer.valueOf(obj));
			}
			else {
				if(obj.equals("+")) {
					int sum=0;
					for(int i=0;i<2;i++) {
						sum+=stk.peek();
						stk.pop();
					}
					stk.push(sum);
				}
				else if(obj.equals("-")) {
					int sum=stk.peek();stk.pop();
					sum=stk.peek()-sum;stk.pop();
					stk.push(sum);
				}
				else if(obj.equals("*")) {
					int sum=1;
					for(int i=0;i<2;i++) {
						sum*=stk.peek();
						stk.pop();
					}
					stk.push(sum);
				}
			}
			
		}
		System.out.println(stk.peek());
		
	}

} Main public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		Stack<Integer>stk=new Stack<>();
		
		while(cin.hasNext()) {
			String obj=cin.next();
			
			Pattern p=Pattern.compile("^[0-9]*$");
			Matcher m=p.matcher(obj);
			if(m.find()) {
				stk.push(Integer.valueOf(obj));
			}
			else {
				if(obj.equals("+")) {
					int sum=0;
					for(int i=0;i<2;i++) {
						sum+=stk.peek();
						stk.pop();
					}
					stk.push(sum);
				}
				else if(obj.equals("-")) {
					int sum=stk.peek();stk.pop();
					sum=stk.peek()-sum;stk.pop();
					stk.push(sum);
				}
				else if(obj.equals("*")) {
					int sum=1;
					for(int i=0;i<2;i++) {
						sum*=stk.peek();
						stk.pop();
					}
					stk.push(sum);
				}
			}
			
		}
		System.out.println(stk.peek());
		
	} main {
		Scanner cin=new Scanner(System.in);
		Stack<Integer>stk=new Stack<>();
		
		while(cin.hasNext()) {
			String obj=cin.next();
			
			Pattern p=Pattern.compile("^[0-9]*$");
			Matcher m=p.matcher(obj);
			if(m.find()) {
				stk.push(Integer.valueOf(obj));
			}
			else {
				if(obj.equals("+")) {
					int sum=0;
					for(int i=0;i<2;i++) {
						sum+=stk.peek();
						stk.pop();
					}
					stk.push(sum);
				}
				else if(obj.equals("-")) {
					int sum=stk.peek();stk.pop();
					sum=stk.peek()-sum;stk.pop();
					stk.push(sum);
				}
				else if(obj.equals("*")) {
					int sum=1;
					for(int i=0;i<2;i++) {
						sum*=stk.peek();
						stk.pop();
					}
					stk.push(sum);
				}
			}
			
		}
		System.out.println(stk.peek());
		
	} Scanner cin=new Scanner(System.in); cin new Scanner(System.in) Stack<Integer>stk=new Stack<>(); stk new Stack<>() while(cin.hasNext()) {
			String obj=cin.next();
			
			Pattern p=Pattern.compile("^[0-9]*$");
			Matcher m=p.matcher(obj);
			if(m.find()) {
				stk.push(Integer.valueOf(obj));
			}
			else {
				if(obj.equals("+")) {
					int sum=0;
					for(int i=0;i<2;i++) {
						sum+=stk.peek();
						stk.pop();
					}
					stk.push(sum);
				}
				else if(obj.equals("-")) {
					int sum=stk.peek();stk.pop();
					sum=stk.peek()-sum;stk.pop();
					stk.push(sum);
				}
				else if(obj.equals("*")) {
					int sum=1;
					for(int i=0;i<2;i++) {
						sum*=stk.peek();
						stk.pop();
					}
					stk.push(sum);
				}
			}
			
		} cin.hasNext() cin.hasNext cin {
			String obj=cin.next();
			
			Pattern p=Pattern.compile("^[0-9]*$");
			Matcher m=p.matcher(obj);
			if(m.find()) {
				stk.push(Integer.valueOf(obj));
			}
			else {
				if(obj.equals("+")) {
					int sum=0;
					for(int i=0;i<2;i++) {
						sum+=stk.peek();
						stk.pop();
					}
					stk.push(sum);
				}
				else if(obj.equals("-")) {
					int sum=stk.peek();stk.pop();
					sum=stk.peek()-sum;stk.pop();
					stk.push(sum);
				}
				else if(obj.equals("*")) {
					int sum=1;
					for(int i=0;i<2;i++) {
						sum*=stk.peek();
						stk.pop();
					}
					stk.push(sum);
				}
			}
			
		} String obj=cin.next(); obj cin.next() cin.next cin Pattern p=Pattern.compile("^[0-9]*$"); p Pattern.compile("^[0-9]*$") Pattern.compile Pattern "^[0-9]*$" Matcher m=p.matcher(obj); m p.matcher(obj) p.matcher p obj if(m.find()) {
				stk.push(Integer.valueOf(obj));
			}
			else {
				if(obj.equals("+")) {
					int sum=0;
					for(int i=0;i<2;i++) {
						sum+=stk.peek();
						stk.pop();
					}
					stk.push(sum);
				}
				else if(obj.equals("-")) {
					int sum=stk.peek();stk.pop();
					sum=stk.peek()-sum;stk.pop();
					stk.push(sum);
				}
				else if(obj.equals("*")) {
					int sum=1;
					for(int i=0;i<2;i++) {
						sum*=stk.peek();
						stk.pop();
					}
					stk.push(sum);
				}
			} m.find() m.find m {
				stk.push(Integer.valueOf(obj));
			} stk.push(Integer.valueOf(obj)) stk.push stk Integer.valueOf(obj) Integer.valueOf Integer obj {
				if(obj.equals("+")) {
					int sum=0;
					for(int i=0;i<2;i++) {
						sum+=stk.peek();
						stk.pop();
					}
					stk.push(sum);
				}
				else if(obj.equals("-")) {
					int sum=stk.peek();stk.pop();
					sum=stk.peek()-sum;stk.pop();
					stk.push(sum);
				}
				else if(obj.equals("*")) {
					int sum=1;
					for(int i=0;i<2;i++) {
						sum*=stk.peek();
						stk.pop();
					}
					stk.push(sum);
				}
			} if(obj.equals("+")) {
					int sum=0;
					for(int i=0;i<2;i++) {
						sum+=stk.peek();
						stk.pop();
					}
					stk.push(sum);
				}
				else if(obj.equals("-")) {
					int sum=stk.peek();stk.pop();
					sum=stk.peek()-sum;stk.pop();
					stk.push(sum);
				}
				else if(obj.equals("*")) {
					int sum=1;
					for(int i=0;i<2;i++) {
						sum*=stk.peek();
						stk.pop();
					}
					stk.push(sum);
				} obj.equals("+") obj.equals obj "+" {
					int sum=0;
					for(int i=0;i<2;i++) {
						sum+=stk.peek();
						stk.pop();
					}
					stk.push(sum);
				} int sum=0; sum 0 for(int i=0;i<2;i++) {
						sum+=stk.peek();
						stk.pop();
					} int i=0; int i=0; i 0 i<2 i 2 i++ i++ i {
						sum+=stk.peek();
						stk.pop();
					} {
						sum+=stk.peek();
						stk.pop();
					} sum+=stk.peek() sum stk.peek() stk.peek stk stk.pop() stk.pop stk stk.push(sum) stk.push stk sum if(obj.equals("-")) {
					int sum=stk.peek();stk.pop();
					sum=stk.peek()-sum;stk.pop();
					stk.push(sum);
				}
				else if(obj.equals("*")) {
					int sum=1;
					for(int i=0;i<2;i++) {
						sum*=stk.peek();
						stk.pop();
					}
					stk.push(sum);
				} obj.equals("-") obj.equals obj "-" {
					int sum=stk.peek();stk.pop();
					sum=stk.peek()-sum;stk.pop();
					stk.push(sum);
				} int sum=stk.peek(); sum stk.peek() stk.peek stk stk.pop() stk.pop stk sum=stk.peek()-sum sum stk.peek()-sum stk.peek() stk.peek stk sum stk.pop() stk.pop stk stk.push(sum) stk.push stk sum if(obj.equals("*")) {
					int sum=1;
					for(int i=0;i<2;i++) {
						sum*=stk.peek();
						stk.pop();
					}
					stk.push(sum);
				} obj.equals("*") obj.equals obj "*" {
					int sum=1;
					for(int i=0;i<2;i++) {
						sum*=stk.peek();
						stk.pop();
					}
					stk.push(sum);
				} int sum=1; sum 1 for(int i=0;i<2;i++) {
						sum*=stk.peek();
						stk.pop();
					} int i=0; int i=0; i 0 i<2 i 2 i++ i++ i {
						sum*=stk.peek();
						stk.pop();
					} {
						sum*=stk.peek();
						stk.pop();
					} sum*=stk.peek() sum stk.peek() stk.peek stk stk.pop() stk.pop stk stk.push(sum) stk.push stk sum System.out.println(stk.peek()) System.out.println System.out System System.out stk.peek() stk.peek stk String[] args args public class Main {

	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		Stack<Integer>stk=new Stack<>();
		
		while(cin.hasNext()) {
			String obj=cin.next();
			
			Pattern p=Pattern.compile("^[0-9]*$");
			Matcher m=p.matcher(obj);
			if(m.find()) {
				stk.push(Integer.valueOf(obj));
			}
			else {
				if(obj.equals("+")) {
					int sum=0;
					for(int i=0;i<2;i++) {
						sum+=stk.peek();
						stk.pop();
					}
					stk.push(sum);
				}
				else if(obj.equals("-")) {
					int sum=stk.peek();stk.pop();
					sum=stk.peek()-sum;stk.pop();
					stk.push(sum);
				}
				else if(obj.equals("*")) {
					int sum=1;
					for(int i=0;i<2;i++) {
						sum*=stk.peek();
						stk.pop();
					}
					stk.push(sum);
				}
			}
			
		}
		System.out.println(stk.peek());
		
	}

} public class Main {

	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		Stack<Integer>stk=new Stack<>();
		
		while(cin.hasNext()) {
			String obj=cin.next();
			
			Pattern p=Pattern.compile("^[0-9]*$");
			Matcher m=p.matcher(obj);
			if(m.find()) {
				stk.push(Integer.valueOf(obj));
			}
			else {
				if(obj.equals("+")) {
					int sum=0;
					for(int i=0;i<2;i++) {
						sum+=stk.peek();
						stk.pop();
					}
					stk.push(sum);
				}
				else if(obj.equals("-")) {
					int sum=stk.peek();stk.pop();
					sum=stk.peek()-sum;stk.pop();
					stk.push(sum);
				}
				else if(obj.equals("*")) {
					int sum=1;
					for(int i=0;i<2;i++) {
						sum*=stk.peek();
						stk.pop();
					}
					stk.push(sum);
				}
			}
			
		}
		System.out.println(stk.peek());
		
	}

} Main
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Main {

	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		Stack<Integer>stk=new Stack<>();
		
		while(cin.hasNext()) {
			String obj=cin.next();
			
			Pattern p=Pattern.compile("^[0-9]*$");
			Matcher m=p.matcher(obj);
			if(m.find()) {
				stk.push(Integer.valueOf(obj));
			}
			else {
				if(obj.equals("+")) {
					int sum=0;
					for(int i=0;i<2;i++) {
						sum+=stk.peek();
						stk.pop();
					}
					stk.push(sum);
				}
				else if(obj.equals("-")) {
					int sum=stk.peek();stk.pop();
					sum=stk.peek()-sum;stk.pop();
					stk.push(sum);
				}
				else if(obj.equals("*")) {
					int sum=1;
					for(int i=0;i<2;i++) {
						sum*=stk.peek();
						stk.pop();
					}
					stk.push(sum);
				}
			}
			
		}
		System.out.println(stk.peek());
		
	}

}

