import java.io.*;
import java.util.*;

class Main{
	public static void main(String[] args)throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String[] A=br.readLine().split("\\s+");
		LinkedList<Integer> stack=new LinkedList<Integer>();
		for (int i = 0; i < A.length; i++) {
			if ('0'<=A[i].charAt(0) && A[i].charAt(0)<='9') {
					int num=Integer.parseInt(A[i]);				
					stack.push(num);
			}else{
				
				int b=stack.pop();
				int a=stack.pop();
			    int c=0;
			    if('+'==A[i].charAt(0)){
			    	c=a+b;
			    }else if('-'==A[i].charAt(0)){
			    	c=a-b;
			    }else if('*'==A[i].charAt(0)){
			    	c=a*b;
			    }else{
			    	System.out.println("bad");
			    }
			    stack.push(c);		    
			}
			
		}
		System.out.println(stack.pop());
	}
} import java.io.*; io.* java import java.util.*; util.* java class Main{
	public static void main(String[] args)throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String[] A=br.readLine().split("\\s+");
		LinkedList<Integer> stack=new LinkedList<Integer>();
		for (int i = 0; i < A.length; i++) {
			if ('0'<=A[i].charAt(0) && A[i].charAt(0)<='9') {
					int num=Integer.parseInt(A[i]);				
					stack.push(num);
			}else{
				
				int b=stack.pop();
				int a=stack.pop();
			    int c=0;
			    if('+'==A[i].charAt(0)){
			    	c=a+b;
			    }else if('-'==A[i].charAt(0)){
			    	c=a-b;
			    }else if('*'==A[i].charAt(0)){
			    	c=a*b;
			    }else{
			    	System.out.println("bad");
			    }
			    stack.push(c);		    
			}
			
		}
		System.out.println(stack.pop());
	}
} Main public static void main(String[] args)throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String[] A=br.readLine().split("\\s+");
		LinkedList<Integer> stack=new LinkedList<Integer>();
		for (int i = 0; i < A.length; i++) {
			if ('0'<=A[i].charAt(0) && A[i].charAt(0)<='9') {
					int num=Integer.parseInt(A[i]);				
					stack.push(num);
			}else{
				
				int b=stack.pop();
				int a=stack.pop();
			    int c=0;
			    if('+'==A[i].charAt(0)){
			    	c=a+b;
			    }else if('-'==A[i].charAt(0)){
			    	c=a-b;
			    }else if('*'==A[i].charAt(0)){
			    	c=a*b;
			    }else{
			    	System.out.println("bad");
			    }
			    stack.push(c);		    
			}
			
		}
		System.out.println(stack.pop());
	} main {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String[] A=br.readLine().split("\\s+");
		LinkedList<Integer> stack=new LinkedList<Integer>();
		for (int i = 0; i < A.length; i++) {
			if ('0'<=A[i].charAt(0) && A[i].charAt(0)<='9') {
					int num=Integer.parseInt(A[i]);				
					stack.push(num);
			}else{
				
				int b=stack.pop();
				int a=stack.pop();
			    int c=0;
			    if('+'==A[i].charAt(0)){
			    	c=a+b;
			    }else if('-'==A[i].charAt(0)){
			    	c=a-b;
			    }else if('*'==A[i].charAt(0)){
			    	c=a*b;
			    }else{
			    	System.out.println("bad");
			    }
			    stack.push(c);		    
			}
			
		}
		System.out.println(stack.pop());
	} BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] A=br.readLine().split("\\s+"); A br.readLine().split("\\s+") br.readLine().split br.readLine() br.readLine br "\\s+" LinkedList<Integer> stack=new LinkedList<Integer>(); stack new LinkedList<Integer>() for (int i = 0; i < A.length; i++) {
			if ('0'<=A[i].charAt(0) && A[i].charAt(0)<='9') {
					int num=Integer.parseInt(A[i]);				
					stack.push(num);
			}else{
				
				int b=stack.pop();
				int a=stack.pop();
			    int c=0;
			    if('+'==A[i].charAt(0)){
			    	c=a+b;
			    }else if('-'==A[i].charAt(0)){
			    	c=a-b;
			    }else if('*'==A[i].charAt(0)){
			    	c=a*b;
			    }else{
			    	System.out.println("bad");
			    }
			    stack.push(c);		    
			}
			
		} int i = 0; int i = 0; i 0 i < A.length i A.length A A.length i++ i++ i {
			if ('0'<=A[i].charAt(0) && A[i].charAt(0)<='9') {
					int num=Integer.parseInt(A[i]);				
					stack.push(num);
			}else{
				
				int b=stack.pop();
				int a=stack.pop();
			    int c=0;
			    if('+'==A[i].charAt(0)){
			    	c=a+b;
			    }else if('-'==A[i].charAt(0)){
			    	c=a-b;
			    }else if('*'==A[i].charAt(0)){
			    	c=a*b;
			    }else{
			    	System.out.println("bad");
			    }
			    stack.push(c);		    
			}
			
		} {
			if ('0'<=A[i].charAt(0) && A[i].charAt(0)<='9') {
					int num=Integer.parseInt(A[i]);				
					stack.push(num);
			}else{
				
				int b=stack.pop();
				int a=stack.pop();
			    int c=0;
			    if('+'==A[i].charAt(0)){
			    	c=a+b;
			    }else if('-'==A[i].charAt(0)){
			    	c=a-b;
			    }else if('*'==A[i].charAt(0)){
			    	c=a*b;
			    }else{
			    	System.out.println("bad");
			    }
			    stack.push(c);		    
			}
			
		} if ('0'<=A[i].charAt(0) && A[i].charAt(0)<='9') {
					int num=Integer.parseInt(A[i]);				
					stack.push(num);
			}else{
				
				int b=stack.pop();
				int a=stack.pop();
			    int c=0;
			    if('+'==A[i].charAt(0)){
			    	c=a+b;
			    }else if('-'==A[i].charAt(0)){
			    	c=a-b;
			    }else if('*'==A[i].charAt(0)){
			    	c=a*b;
			    }else{
			    	System.out.println("bad");
			    }
			    stack.push(c);		    
			} '0'<=A[i].charAt(0) && A[i].charAt(0)<='9' '0'<=A[i].charAt(0) '0' A[i].charAt(0) A[i].charAt A[i] A i 0 A[i].charAt(0)<='9' A[i].charAt(0) A[i].charAt A[i] A i 0 '9' {
					int num=Integer.parseInt(A[i]);				
					stack.push(num);
			} int num=Integer.parseInt(A[i]); num Integer.parseInt(A[i]) Integer.parseInt Integer A[i] A i stack.push(num) stack.push stack num {
				
				int b=stack.pop();
				int a=stack.pop();
			    int c=0;
			    if('+'==A[i].charAt(0)){
			    	c=a+b;
			    }else if('-'==A[i].charAt(0)){
			    	c=a-b;
			    }else if('*'==A[i].charAt(0)){
			    	c=a*b;
			    }else{
			    	System.out.println("bad");
			    }
			    stack.push(c);		    
			} int b=stack.pop(); b stack.pop() stack.pop stack int a=stack.pop(); a stack.pop() stack.pop stack int c=0; c 0 if('+'==A[i].charAt(0)){
			    	c=a+b;
			    }else if('-'==A[i].charAt(0)){
			    	c=a-b;
			    }else if('*'==A[i].charAt(0)){
			    	c=a*b;
			    }else{
			    	System.out.println("bad");
			    } '+'==A[i].charAt(0) '+' A[i].charAt(0) A[i].charAt A[i] A i 0 {
			    	c=a+b;
			    } c=a+b c a+b a b if('-'==A[i].charAt(0)){
			    	c=a-b;
			    }else if('*'==A[i].charAt(0)){
			    	c=a*b;
			    }else{
			    	System.out.println("bad");
			    } '-'==A[i].charAt(0) '-' A[i].charAt(0) A[i].charAt A[i] A i 0 {
			    	c=a-b;
			    } c=a-b c a-b a b if('*'==A[i].charAt(0)){
			    	c=a*b;
			    }else{
			    	System.out.println("bad");
			    } '*'==A[i].charAt(0) '*' A[i].charAt(0) A[i].charAt A[i] A i 0 {
			    	c=a*b;
			    } c=a*b c a*b a b {
			    	System.out.println("bad");
			    } System.out.println("bad") System.out.println System.out System System.out "bad" stack.push(c) stack.push stack c System.out.println(stack.pop()) System.out.println System.out System System.out stack.pop() stack.pop stack String[] args args
import java.io.*;
import java.util.*;

class Main{
	public static void main(String[] args)throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String[] A=br.readLine().split("\\s+");
		LinkedList<Integer> stack=new LinkedList<Integer>();
		for (int i = 0; i < A.length; i++) {
			if ('0'<=A[i].charAt(0) && A[i].charAt(0)<='9') {
					int num=Integer.parseInt(A[i]);				
					stack.push(num);
			}else{
				
				int b=stack.pop();
				int a=stack.pop();
			    int c=0;
			    if('+'==A[i].charAt(0)){
			    	c=a+b;
			    }else if('-'==A[i].charAt(0)){
			    	c=a-b;
			    }else if('*'==A[i].charAt(0)){
			    	c=a*b;
			    }else{
			    	System.out.println("bad");
			    }
			    stack.push(c);		    
			}
			
		}
		System.out.println(stack.pop());
	}
}