import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;


public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		//????????????????????????
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		
		//?????????
		String[] arrayString = bf.readLine().split(" ");
		
		//Stack
		Stack stack=new Stack();
		
		for(int i=0;i<arrayString.length;i++){
			String str=arrayString[i];
			if(str.equals("+")){
				stack.push(stack.pop()+stack.pop());
			}else if(str.equals("-")){
				int a=stack.pop();
				int b=stack.pop();
				stack.push(b-a);
			}else if(str.equals("*")){
				stack.push(stack.pop()*stack.pop());
			}else{
				stack.push(Integer.parseInt(str));
			}
		}
		
		System.out.println(stack.pop());
	}

}
class Stack{
	ArrayList<Integer> array;
	
	public Stack(){
		array=new ArrayList<Integer>();
	}
	
	public void push(int i){
		array.add(i);
	}
	
	public int pop(){
		int result=array.get(array.size()-1);
		array.remove(array.size()-1);
		return result;
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayList; ArrayList java.util public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		//????????????????????????
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		
		//?????????
		String[] arrayString = bf.readLine().split(" ");
		
		//Stack
		Stack stack=new Stack();
		
		for(int i=0;i<arrayString.length;i++){
			String str=arrayString[i];
			if(str.equals("+")){
				stack.push(stack.pop()+stack.pop());
			}else if(str.equals("-")){
				int a=stack.pop();
				int b=stack.pop();
				stack.push(b-a);
			}else if(str.equals("*")){
				stack.push(stack.pop()*stack.pop());
			}else{
				stack.push(Integer.parseInt(str));
			}
		}
		
		System.out.println(stack.pop());
	}

} Main public static void main(String[] args) throws NumberFormatException, IOException {
		//????????????????????????
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		
		//?????????
		String[] arrayString = bf.readLine().split(" ");
		
		//Stack
		Stack stack=new Stack();
		
		for(int i=0;i<arrayString.length;i++){
			String str=arrayString[i];
			if(str.equals("+")){
				stack.push(stack.pop()+stack.pop());
			}else if(str.equals("-")){
				int a=stack.pop();
				int b=stack.pop();
				stack.push(b-a);
			}else if(str.equals("*")){
				stack.push(stack.pop()*stack.pop());
			}else{
				stack.push(Integer.parseInt(str));
			}
		}
		
		System.out.println(stack.pop());
	} main {
		//????????????????????????
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		
		//?????????
		String[] arrayString = bf.readLine().split(" ");
		
		//Stack
		Stack stack=new Stack();
		
		for(int i=0;i<arrayString.length;i++){
			String str=arrayString[i];
			if(str.equals("+")){
				stack.push(stack.pop()+stack.pop());
			}else if(str.equals("-")){
				int a=stack.pop();
				int b=stack.pop();
				stack.push(b-a);
			}else if(str.equals("*")){
				stack.push(stack.pop()*stack.pop());
			}else{
				stack.push(Integer.parseInt(str));
			}
		}
		
		System.out.println(stack.pop());
	} BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); bf new BufferedReader(new InputStreamReader(System.in)) String[] arrayString = bf.readLine().split(" "); arrayString bf.readLine().split(" ") bf.readLine().split bf.readLine() bf.readLine bf " " Stack stack=new Stack(); stack new Stack() for(int i=0;i<arrayString.length;i++){
			String str=arrayString[i];
			if(str.equals("+")){
				stack.push(stack.pop()+stack.pop());
			}else if(str.equals("-")){
				int a=stack.pop();
				int b=stack.pop();
				stack.push(b-a);
			}else if(str.equals("*")){
				stack.push(stack.pop()*stack.pop());
			}else{
				stack.push(Integer.parseInt(str));
			}
		} int i=0; int i=0; i 0 i<arrayString.length i arrayString.length arrayString arrayString.length i++ i++ i {
			String str=arrayString[i];
			if(str.equals("+")){
				stack.push(stack.pop()+stack.pop());
			}else if(str.equals("-")){
				int a=stack.pop();
				int b=stack.pop();
				stack.push(b-a);
			}else if(str.equals("*")){
				stack.push(stack.pop()*stack.pop());
			}else{
				stack.push(Integer.parseInt(str));
			}
		} {
			String str=arrayString[i];
			if(str.equals("+")){
				stack.push(stack.pop()+stack.pop());
			}else if(str.equals("-")){
				int a=stack.pop();
				int b=stack.pop();
				stack.push(b-a);
			}else if(str.equals("*")){
				stack.push(stack.pop()*stack.pop());
			}else{
				stack.push(Integer.parseInt(str));
			}
		} String str=arrayString[i]; str arrayString[i] arrayString i if(str.equals("+")){
				stack.push(stack.pop()+stack.pop());
			}else if(str.equals("-")){
				int a=stack.pop();
				int b=stack.pop();
				stack.push(b-a);
			}else if(str.equals("*")){
				stack.push(stack.pop()*stack.pop());
			}else{
				stack.push(Integer.parseInt(str));
			} str.equals("+") str.equals str "+" {
				stack.push(stack.pop()+stack.pop());
			} stack.push(stack.pop()+stack.pop()) stack.push stack stack.pop()+stack.pop() stack.pop() stack.pop stack stack.pop() stack.pop stack if(str.equals("-")){
				int a=stack.pop();
				int b=stack.pop();
				stack.push(b-a);
			}else if(str.equals("*")){
				stack.push(stack.pop()*stack.pop());
			}else{
				stack.push(Integer.parseInt(str));
			} str.equals("-") str.equals str "-" {
				int a=stack.pop();
				int b=stack.pop();
				stack.push(b-a);
			} int a=stack.pop(); a stack.pop() stack.pop stack int b=stack.pop(); b stack.pop() stack.pop stack stack.push(b-a) stack.push stack b-a b a if(str.equals("*")){
				stack.push(stack.pop()*stack.pop());
			}else{
				stack.push(Integer.parseInt(str));
			} str.equals("*") str.equals str "*" {
				stack.push(stack.pop()*stack.pop());
			} stack.push(stack.pop()*stack.pop()) stack.push stack stack.pop()*stack.pop() stack.pop() stack.pop stack stack.pop() stack.pop stack {
				stack.push(Integer.parseInt(str));
			} stack.push(Integer.parseInt(str)) stack.push stack Integer.parseInt(str) Integer.parseInt Integer str System.out.println(stack.pop()) System.out.println System.out System System.out stack.pop() stack.pop stack String[] args args class Stack{
	ArrayList<Integer> array;
	
	public Stack(){
		array=new ArrayList<Integer>();
	}
	
	public void push(int i){
		array.add(i);
	}
	
	public int pop(){
		int result=array.get(array.size()-1);
		array.remove(array.size()-1);
		return result;
	}
} Stack ArrayList<Integer> array; array public Stack(){
		array=new ArrayList<Integer>();
	} Stack {
		array=new ArrayList<Integer>();
	} array=new ArrayList<Integer>() array new ArrayList<Integer>() public void push(int i){
		array.add(i);
	} push {
		array.add(i);
	} array.add(i) array.add array i int i i public int pop(){
		int result=array.get(array.size()-1);
		array.remove(array.size()-1);
		return result;
	} pop {
		int result=array.get(array.size()-1);
		array.remove(array.size()-1);
		return result;
	} int result=array.get(array.size()-1); result array.get(array.size()-1) array.get array array.size()-1 array.size() array.size array 1 array.remove(array.size()-1) array.remove array array.size()-1 array.size() array.size array 1 return result; result public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		//????????????????????????
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		
		//?????????
		String[] arrayString = bf.readLine().split(" ");
		
		//Stack
		Stack stack=new Stack();
		
		for(int i=0;i<arrayString.length;i++){
			String str=arrayString[i];
			if(str.equals("+")){
				stack.push(stack.pop()+stack.pop());
			}else if(str.equals("-")){
				int a=stack.pop();
				int b=stack.pop();
				stack.push(b-a);
			}else if(str.equals("*")){
				stack.push(stack.pop()*stack.pop());
			}else{
				stack.push(Integer.parseInt(str));
			}
		}
		
		System.out.println(stack.pop());
	}

} public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		//????????????????????????
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		
		//?????????
		String[] arrayString = bf.readLine().split(" ");
		
		//Stack
		Stack stack=new Stack();
		
		for(int i=0;i<arrayString.length;i++){
			String str=arrayString[i];
			if(str.equals("+")){
				stack.push(stack.pop()+stack.pop());
			}else if(str.equals("-")){
				int a=stack.pop();
				int b=stack.pop();
				stack.push(b-a);
			}else if(str.equals("*")){
				stack.push(stack.pop()*stack.pop());
			}else{
				stack.push(Integer.parseInt(str));
			}
		}
		
		System.out.println(stack.pop());
	}

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;


public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		//????????????????????????
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		
		//?????????
		String[] arrayString = bf.readLine().split(" ");
		
		//Stack
		Stack stack=new Stack();
		
		for(int i=0;i<arrayString.length;i++){
			String str=arrayString[i];
			if(str.equals("+")){
				stack.push(stack.pop()+stack.pop());
			}else if(str.equals("-")){
				int a=stack.pop();
				int b=stack.pop();
				stack.push(b-a);
			}else if(str.equals("*")){
				stack.push(stack.pop()*stack.pop());
			}else{
				stack.push(Integer.parseInt(str));
			}
		}
		
		System.out.println(stack.pop());
	}

}
class Stack{
	ArrayList<Integer> array;
	
	public Stack(){
		array=new ArrayList<Integer>();
	}
	
	public void push(int i){
		array.add(i);
	}
	
	public int pop(){
		int result=array.get(array.size()-1);
		array.remove(array.size()-1);
		return result;
	}
}