import java.util.Scanner;

class Main{
	
	static int top;
	static int [] stack = new int[1000];
  
	static void push(int x){
		stack[++top] = x;
	}

	static int pop(){
		top--;
		return stack[top + 1];
	}
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s;
		int a,b;
		top = 0;
		while(sc.hasNext()){ 
            		s = sc.next();
            		if(s.equals("+")){
                		a = pop();
                		b = pop();
                		push(a + b);
            		}
            		else if(s.equals("-")){
                		a = pop();
                		b = pop();
                		push(b - a);
            		}
            		else if(s.equals("*")){
                		a = pop();
                		b = pop();
                		push(a * b);
            		}
            		else{
                		push(Integer.parseInt(s));	
            		}
		}

		System.out.println(pop());
	}
} import java.util.Scanner; Scanner java.util class Main{
	
	static int top;
	static int [] stack = new int[1000];
  
	static void push(int x){
		stack[++top] = x;
	}

	static int pop(){
		top--;
		return stack[top + 1];
	}
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s;
		int a,b;
		top = 0;
		while(sc.hasNext()){ 
            		s = sc.next();
            		if(s.equals("+")){
                		a = pop();
                		b = pop();
                		push(a + b);
            		}
            		else if(s.equals("-")){
                		a = pop();
                		b = pop();
                		push(b - a);
            		}
            		else if(s.equals("*")){
                		a = pop();
                		b = pop();
                		push(a * b);
            		}
            		else{
                		push(Integer.parseInt(s));	
            		}
		}

		System.out.println(pop());
	}
} Main static int top; top static int [] stack = new int[1000]; stack new int[1000] 1000 static void push(int x){
		stack[++top] = x;
	} push {
		stack[++top] = x;
	} stack[++top] = x stack[++top] stack ++top top x int x x static int pop(){
		top--;
		return stack[top + 1];
	} pop {
		top--;
		return stack[top + 1];
	} top-- top return stack[top + 1]; stack[top + 1] stack top + 1 top 1 public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s;
		int a,b;
		top = 0;
		while(sc.hasNext()){ 
            		s = sc.next();
            		if(s.equals("+")){
                		a = pop();
                		b = pop();
                		push(a + b);
            		}
            		else if(s.equals("-")){
                		a = pop();
                		b = pop();
                		push(b - a);
            		}
            		else if(s.equals("*")){
                		a = pop();
                		b = pop();
                		push(a * b);
            		}
            		else{
                		push(Integer.parseInt(s));	
            		}
		}

		System.out.println(pop());
	} main {
		Scanner sc = new Scanner(System.in);
		String s;
		int a,b;
		top = 0;
		while(sc.hasNext()){ 
            		s = sc.next();
            		if(s.equals("+")){
                		a = pop();
                		b = pop();
                		push(a + b);
            		}
            		else if(s.equals("-")){
                		a = pop();
                		b = pop();
                		push(b - a);
            		}
            		else if(s.equals("*")){
                		a = pop();
                		b = pop();
                		push(a * b);
            		}
            		else{
                		push(Integer.parseInt(s));	
            		}
		}

		System.out.println(pop());
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s; s int a a b; b top = 0 top 0 while(sc.hasNext()){ 
            		s = sc.next();
            		if(s.equals("+")){
                		a = pop();
                		b = pop();
                		push(a + b);
            		}
            		else if(s.equals("-")){
                		a = pop();
                		b = pop();
                		push(b - a);
            		}
            		else if(s.equals("*")){
                		a = pop();
                		b = pop();
                		push(a * b);
            		}
            		else{
                		push(Integer.parseInt(s));	
            		}
		} sc.hasNext() sc.hasNext sc { 
            		s = sc.next();
            		if(s.equals("+")){
                		a = pop();
                		b = pop();
                		push(a + b);
            		}
            		else if(s.equals("-")){
                		a = pop();
                		b = pop();
                		push(b - a);
            		}
            		else if(s.equals("*")){
                		a = pop();
                		b = pop();
                		push(a * b);
            		}
            		else{
                		push(Integer.parseInt(s));	
            		}
		} s = sc.next() s sc.next() sc.next sc if(s.equals("+")){
                		a = pop();
                		b = pop();
                		push(a + b);
            		}
            		else if(s.equals("-")){
                		a = pop();
                		b = pop();
                		push(b - a);
            		}
            		else if(s.equals("*")){
                		a = pop();
                		b = pop();
                		push(a * b);
            		}
            		else{
                		push(Integer.parseInt(s));	
            		} s.equals("+") s.equals s "+" {
                		a = pop();
                		b = pop();
                		push(a + b);
            		} a = pop() a pop() pop b = pop() b pop() pop push(a + b) push a + b a b if(s.equals("-")){
                		a = pop();
                		b = pop();
                		push(b - a);
            		}
            		else if(s.equals("*")){
                		a = pop();
                		b = pop();
                		push(a * b);
            		}
            		else{
                		push(Integer.parseInt(s));	
            		} s.equals("-") s.equals s "-" {
                		a = pop();
                		b = pop();
                		push(b - a);
            		} a = pop() a pop() pop b = pop() b pop() pop push(b - a) push b - a b a if(s.equals("*")){
                		a = pop();
                		b = pop();
                		push(a * b);
            		}
            		else{
                		push(Integer.parseInt(s));	
            		} s.equals("*") s.equals s "*" {
                		a = pop();
                		b = pop();
                		push(a * b);
            		} a = pop() a pop() pop b = pop() b pop() pop push(a * b) push a * b a b {
                		push(Integer.parseInt(s));	
            		} push(Integer.parseInt(s)) push Integer.parseInt(s) Integer.parseInt Integer s System.out.println(pop()) System.out.println System.out System System.out pop() pop String[] args args
import java.util.Scanner;

class Main{
	
	static int top;
	static int [] stack = new int[1000];
  
	static void push(int x){
		stack[++top] = x;
	}

	static int pop(){
		top--;
		return stack[top + 1];
	}
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s;
		int a,b;
		top = 0;
		while(sc.hasNext()){ 
            		s = sc.next();
            		if(s.equals("+")){
                		a = pop();
                		b = pop();
                		push(a + b);
            		}
            		else if(s.equals("-")){
                		a = pop();
                		b = pop();
                		push(b - a);
            		}
            		else if(s.equals("*")){
                		a = pop();
                		b = pop();
                		push(a * b);
            		}
            		else{
                		push(Integer.parseInt(s));	
            		}
		}

		System.out.println(pop());
	}
}