import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;
class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)){
			Deque<Integer> operando=new ArrayDeque<>();
			boolean isEOF=false;
			while(sc.hasNext()){
				String order=sc.next();
				boolean isOperator = false;
				String[] Operator= new String[3];
				Operator[0]=new String("+");
				Operator[1]=new String("*");
				Operator[2]=new String("-");
				for(String s: Operator){
					if(order.equals(s)) isOperator=true;
				}
				//if(order.equals("EOF")) isEOF=true;
				if(!isEOF){
					if(isOperator){
						int a = operando.pollFirst();
						int b = operando.pollFirst();
						operando.addFirst(calc(a,b,order));
					}else{
						operando.addFirst(Integer.parseInt(order));
					}
				}
			}
			System.out.println(operando.pollFirst());
		}
	}
	public static int calc(int a, int b, String s){
		int ans=0;
		if(s.equals("+"))ans= a+b;
		if(s.equals("-"))ans= b-a;
		if(s.equals("*"))ans= a*b;
		return ans;
	}
} import java.util.ArrayDeque; ArrayDeque java.util import java.util.Deque; Deque java.util import java.util.Scanner; Scanner java.util class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)){
			Deque<Integer> operando=new ArrayDeque<>();
			boolean isEOF=false;
			while(sc.hasNext()){
				String order=sc.next();
				boolean isOperator = false;
				String[] Operator= new String[3];
				Operator[0]=new String("+");
				Operator[1]=new String("*");
				Operator[2]=new String("-");
				for(String s: Operator){
					if(order.equals(s)) isOperator=true;
				}
				//if(order.equals("EOF")) isEOF=true;
				if(!isEOF){
					if(isOperator){
						int a = operando.pollFirst();
						int b = operando.pollFirst();
						operando.addFirst(calc(a,b,order));
					}else{
						operando.addFirst(Integer.parseInt(order));
					}
				}
			}
			System.out.println(operando.pollFirst());
		}
	}
	public static int calc(int a, int b, String s){
		int ans=0;
		if(s.equals("+"))ans= a+b;
		if(s.equals("-"))ans= b-a;
		if(s.equals("*"))ans= a*b;
		return ans;
	}
} Main public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)){
			Deque<Integer> operando=new ArrayDeque<>();
			boolean isEOF=false;
			while(sc.hasNext()){
				String order=sc.next();
				boolean isOperator = false;
				String[] Operator= new String[3];
				Operator[0]=new String("+");
				Operator[1]=new String("*");
				Operator[2]=new String("-");
				for(String s: Operator){
					if(order.equals(s)) isOperator=true;
				}
				//if(order.equals("EOF")) isEOF=true;
				if(!isEOF){
					if(isOperator){
						int a = operando.pollFirst();
						int b = operando.pollFirst();
						operando.addFirst(calc(a,b,order));
					}else{
						operando.addFirst(Integer.parseInt(order));
					}
				}
			}
			System.out.println(operando.pollFirst());
		}
	} main {
		try(Scanner sc = new Scanner(System.in)){
			Deque<Integer> operando=new ArrayDeque<>();
			boolean isEOF=false;
			while(sc.hasNext()){
				String order=sc.next();
				boolean isOperator = false;
				String[] Operator= new String[3];
				Operator[0]=new String("+");
				Operator[1]=new String("*");
				Operator[2]=new String("-");
				for(String s: Operator){
					if(order.equals(s)) isOperator=true;
				}
				//if(order.equals("EOF")) isEOF=true;
				if(!isEOF){
					if(isOperator){
						int a = operando.pollFirst();
						int b = operando.pollFirst();
						operando.addFirst(calc(a,b,order));
					}else{
						operando.addFirst(Integer.parseInt(order));
					}
				}
			}
			System.out.println(operando.pollFirst());
		}
	} try(Scanner sc = new Scanner(System.in)){
			Deque<Integer> operando=new ArrayDeque<>();
			boolean isEOF=false;
			while(sc.hasNext()){
				String order=sc.next();
				boolean isOperator = false;
				String[] Operator= new String[3];
				Operator[0]=new String("+");
				Operator[1]=new String("*");
				Operator[2]=new String("-");
				for(String s: Operator){
					if(order.equals(s)) isOperator=true;
				}
				//if(order.equals("EOF")) isEOF=true;
				if(!isEOF){
					if(isOperator){
						int a = operando.pollFirst();
						int b = operando.pollFirst();
						operando.addFirst(calc(a,b,order));
					}else{
						operando.addFirst(Integer.parseInt(order));
					}
				}
			}
			System.out.println(operando.pollFirst());
		} {
			Deque<Integer> operando=new ArrayDeque<>();
			boolean isEOF=false;
			while(sc.hasNext()){
				String order=sc.next();
				boolean isOperator = false;
				String[] Operator= new String[3];
				Operator[0]=new String("+");
				Operator[1]=new String("*");
				Operator[2]=new String("-");
				for(String s: Operator){
					if(order.equals(s)) isOperator=true;
				}
				//if(order.equals("EOF")) isEOF=true;
				if(!isEOF){
					if(isOperator){
						int a = operando.pollFirst();
						int b = operando.pollFirst();
						operando.addFirst(calc(a,b,order));
					}else{
						operando.addFirst(Integer.parseInt(order));
					}
				}
			}
			System.out.println(operando.pollFirst());
		} Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) Deque<Integer> operando=new ArrayDeque<>(); operando new ArrayDeque<>() boolean isEOF=false; isEOF false while(sc.hasNext()){
				String order=sc.next();
				boolean isOperator = false;
				String[] Operator= new String[3];
				Operator[0]=new String("+");
				Operator[1]=new String("*");
				Operator[2]=new String("-");
				for(String s: Operator){
					if(order.equals(s)) isOperator=true;
				}
				//if(order.equals("EOF")) isEOF=true;
				if(!isEOF){
					if(isOperator){
						int a = operando.pollFirst();
						int b = operando.pollFirst();
						operando.addFirst(calc(a,b,order));
					}else{
						operando.addFirst(Integer.parseInt(order));
					}
				}
			} sc.hasNext() sc.hasNext sc {
				String order=sc.next();
				boolean isOperator = false;
				String[] Operator= new String[3];
				Operator[0]=new String("+");
				Operator[1]=new String("*");
				Operator[2]=new String("-");
				for(String s: Operator){
					if(order.equals(s)) isOperator=true;
				}
				//if(order.equals("EOF")) isEOF=true;
				if(!isEOF){
					if(isOperator){
						int a = operando.pollFirst();
						int b = operando.pollFirst();
						operando.addFirst(calc(a,b,order));
					}else{
						operando.addFirst(Integer.parseInt(order));
					}
				}
			} String order=sc.next(); order sc.next() sc.next sc boolean isOperator = false; isOperator false String[] Operator= new String[3]; Operator new String[3] 3 Operator[0]=new String("+") Operator[0] Operator 0 new String("+") Operator[1]=new String("*") Operator[1] Operator 1 new String("*") Operator[2]=new String("-") Operator[2] Operator 2 new String("-") for(String s: Operator){
					if(order.equals(s)) isOperator=true;
				} String s Operator {
					if(order.equals(s)) isOperator=true;
				} {
					if(order.equals(s)) isOperator=true;
				} if(order.equals(s)) isOperator=true; order.equals(s) order.equals order s isOperator=true isOperator true if(!isEOF){
					if(isOperator){
						int a = operando.pollFirst();
						int b = operando.pollFirst();
						operando.addFirst(calc(a,b,order));
					}else{
						operando.addFirst(Integer.parseInt(order));
					}
				} !isEOF isEOF {
					if(isOperator){
						int a = operando.pollFirst();
						int b = operando.pollFirst();
						operando.addFirst(calc(a,b,order));
					}else{
						operando.addFirst(Integer.parseInt(order));
					}
				} if(isOperator){
						int a = operando.pollFirst();
						int b = operando.pollFirst();
						operando.addFirst(calc(a,b,order));
					}else{
						operando.addFirst(Integer.parseInt(order));
					} isOperator {
						int a = operando.pollFirst();
						int b = operando.pollFirst();
						operando.addFirst(calc(a,b,order));
					} int a = operando.pollFirst(); a operando.pollFirst() operando.pollFirst operando int b = operando.pollFirst(); b operando.pollFirst() operando.pollFirst operando operando.addFirst(calc(a,b,order)) operando.addFirst operando calc(a,b,order) calc a b order {
						operando.addFirst(Integer.parseInt(order));
					} operando.addFirst(Integer.parseInt(order)) operando.addFirst operando Integer.parseInt(order) Integer.parseInt Integer order System.out.println(operando.pollFirst()) System.out.println System.out System System.out operando.pollFirst() operando.pollFirst operando String[] args args public static int calc(int a, int b, String s){
		int ans=0;
		if(s.equals("+"))ans= a+b;
		if(s.equals("-"))ans= b-a;
		if(s.equals("*"))ans= a*b;
		return ans;
	} calc {
		int ans=0;
		if(s.equals("+"))ans= a+b;
		if(s.equals("-"))ans= b-a;
		if(s.equals("*"))ans= a*b;
		return ans;
	} int ans=0; ans 0 if(s.equals("+"))ans= a+b; s.equals("+") s.equals s "+" ans= a+b ans a+b a b if(s.equals("-"))ans= b-a; s.equals("-") s.equals s "-" ans= b-a ans b-a b a if(s.equals("*"))ans= a*b; s.equals("*") s.equals s "*" ans= a*b ans a*b a b return ans; ans int a a int b b String s s
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;
class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)){
			Deque<Integer> operando=new ArrayDeque<>();
			boolean isEOF=false;
			while(sc.hasNext()){
				String order=sc.next();
				boolean isOperator = false;
				String[] Operator= new String[3];
				Operator[0]=new String("+");
				Operator[1]=new String("*");
				Operator[2]=new String("-");
				for(String s: Operator){
					if(order.equals(s)) isOperator=true;
				}
				//if(order.equals("EOF")) isEOF=true;
				if(!isEOF){
					if(isOperator){
						int a = operando.pollFirst();
						int b = operando.pollFirst();
						operando.addFirst(calc(a,b,order));
					}else{
						operando.addFirst(Integer.parseInt(order));
					}
				}
			}
			System.out.println(operando.pollFirst());
		}
	}
	public static int calc(int a, int b, String s){
		int ans=0;
		if(s.equals("+"))ans= a+b;
		if(s.equals("-"))ans= b-a;
		if(s.equals("*"))ans= a*b;
		return ans;
	}
}