

import java.util.*;

class Main {
	public static void main(String[] args){
		Scanner input=new Scanner(System.in);
		
		Stack<Integer> stack=new Stack<Integer>();
		
		String expression=input.nextLine();
		
		String[] arrays=expression.split(" ");
		
		for(int i=0;i<arrays.length;i++){
			if(Character.isDigit(arrays[i].charAt(0)))
				stack.add(Integer.parseInt(arrays[i]));
			else if(!Character.isDigit(arrays[i].charAt(0))){
				int number2=stack.pop();
				int number1=stack.pop();
				
				stack.push(add(number1,number2,arrays[i].charAt(0)));
			}
				
		}
		
		System.out.println(stack.pop());
		
		
	}
	
	public static int add(int number1,int number2,char symbol){
		int result=0;
		if(symbol=='+')
			result=number1+number2;
		else if(symbol=='-')
			result=number1-number2;
		else if(symbol=='*')
			result=number1*number2;
		else if(symbol=='/')
			result=number1/number2;
		
		
		return result;
	}

} import java.util.*; util.* java class Main {
	public static void main(String[] args){
		Scanner input=new Scanner(System.in);
		
		Stack<Integer> stack=new Stack<Integer>();
		
		String expression=input.nextLine();
		
		String[] arrays=expression.split(" ");
		
		for(int i=0;i<arrays.length;i++){
			if(Character.isDigit(arrays[i].charAt(0)))
				stack.add(Integer.parseInt(arrays[i]));
			else if(!Character.isDigit(arrays[i].charAt(0))){
				int number2=stack.pop();
				int number1=stack.pop();
				
				stack.push(add(number1,number2,arrays[i].charAt(0)));
			}
				
		}
		
		System.out.println(stack.pop());
		
		
	}
	
	public static int add(int number1,int number2,char symbol){
		int result=0;
		if(symbol=='+')
			result=number1+number2;
		else if(symbol=='-')
			result=number1-number2;
		else if(symbol=='*')
			result=number1*number2;
		else if(symbol=='/')
			result=number1/number2;
		
		
		return result;
	}

} Main public static void main(String[] args){
		Scanner input=new Scanner(System.in);
		
		Stack<Integer> stack=new Stack<Integer>();
		
		String expression=input.nextLine();
		
		String[] arrays=expression.split(" ");
		
		for(int i=0;i<arrays.length;i++){
			if(Character.isDigit(arrays[i].charAt(0)))
				stack.add(Integer.parseInt(arrays[i]));
			else if(!Character.isDigit(arrays[i].charAt(0))){
				int number2=stack.pop();
				int number1=stack.pop();
				
				stack.push(add(number1,number2,arrays[i].charAt(0)));
			}
				
		}
		
		System.out.println(stack.pop());
		
		
	} main {
		Scanner input=new Scanner(System.in);
		
		Stack<Integer> stack=new Stack<Integer>();
		
		String expression=input.nextLine();
		
		String[] arrays=expression.split(" ");
		
		for(int i=0;i<arrays.length;i++){
			if(Character.isDigit(arrays[i].charAt(0)))
				stack.add(Integer.parseInt(arrays[i]));
			else if(!Character.isDigit(arrays[i].charAt(0))){
				int number2=stack.pop();
				int number1=stack.pop();
				
				stack.push(add(number1,number2,arrays[i].charAt(0)));
			}
				
		}
		
		System.out.println(stack.pop());
		
		
	} Scanner input=new Scanner(System.in); input new Scanner(System.in) Stack<Integer> stack=new Stack<Integer>(); stack new Stack<Integer>() String expression=input.nextLine(); expression input.nextLine() input.nextLine input String[] arrays=expression.split(" "); arrays expression.split(" ") expression.split expression " " for(int i=0;i<arrays.length;i++){
			if(Character.isDigit(arrays[i].charAt(0)))
				stack.add(Integer.parseInt(arrays[i]));
			else if(!Character.isDigit(arrays[i].charAt(0))){
				int number2=stack.pop();
				int number1=stack.pop();
				
				stack.push(add(number1,number2,arrays[i].charAt(0)));
			}
				
		} int i=0; int i=0; i 0 i<arrays.length i arrays.length arrays arrays.length i++ i++ i {
			if(Character.isDigit(arrays[i].charAt(0)))
				stack.add(Integer.parseInt(arrays[i]));
			else if(!Character.isDigit(arrays[i].charAt(0))){
				int number2=stack.pop();
				int number1=stack.pop();
				
				stack.push(add(number1,number2,arrays[i].charAt(0)));
			}
				
		} {
			if(Character.isDigit(arrays[i].charAt(0)))
				stack.add(Integer.parseInt(arrays[i]));
			else if(!Character.isDigit(arrays[i].charAt(0))){
				int number2=stack.pop();
				int number1=stack.pop();
				
				stack.push(add(number1,number2,arrays[i].charAt(0)));
			}
				
		} if(Character.isDigit(arrays[i].charAt(0)))
				stack.add(Integer.parseInt(arrays[i]));
			else if(!Character.isDigit(arrays[i].charAt(0))){
				int number2=stack.pop();
				int number1=stack.pop();
				
				stack.push(add(number1,number2,arrays[i].charAt(0)));
			} Character.isDigit(arrays[i].charAt(0)) Character.isDigit Character arrays[i].charAt(0) arrays[i].charAt arrays[i] arrays i 0 stack.add(Integer.parseInt(arrays[i])) stack.add stack Integer.parseInt(arrays[i]) Integer.parseInt Integer arrays[i] arrays i if(!Character.isDigit(arrays[i].charAt(0))){
				int number2=stack.pop();
				int number1=stack.pop();
				
				stack.push(add(number1,number2,arrays[i].charAt(0)));
			} !Character.isDigit(arrays[i].charAt(0)) Character.isDigit(arrays[i].charAt(0)) Character.isDigit Character arrays[i].charAt(0) arrays[i].charAt arrays[i] arrays i 0 {
				int number2=stack.pop();
				int number1=stack.pop();
				
				stack.push(add(number1,number2,arrays[i].charAt(0)));
			} int number2=stack.pop(); number2 stack.pop() stack.pop stack int number1=stack.pop(); number1 stack.pop() stack.pop stack stack.push(add(number1,number2,arrays[i].charAt(0))) stack.push stack add(number1,number2,arrays[i].charAt(0)) add number1 number2 arrays[i].charAt(0) arrays[i].charAt arrays[i] arrays i 0 System.out.println(stack.pop()) System.out.println System.out System System.out stack.pop() stack.pop stack String[] args args public static int add(int number1,int number2,char symbol){
		int result=0;
		if(symbol=='+')
			result=number1+number2;
		else if(symbol=='-')
			result=number1-number2;
		else if(symbol=='*')
			result=number1*number2;
		else if(symbol=='/')
			result=number1/number2;
		
		
		return result;
	} add {
		int result=0;
		if(symbol=='+')
			result=number1+number2;
		else if(symbol=='-')
			result=number1-number2;
		else if(symbol=='*')
			result=number1*number2;
		else if(symbol=='/')
			result=number1/number2;
		
		
		return result;
	} int result=0; result 0 if(symbol=='+')
			result=number1+number2;
		else if(symbol=='-')
			result=number1-number2;
		else if(symbol=='*')
			result=number1*number2;
		else if(symbol=='/')
			result=number1/number2; symbol=='+' symbol '+' result=number1+number2 result number1+number2 number1 number2 if(symbol=='-')
			result=number1-number2;
		else if(symbol=='*')
			result=number1*number2;
		else if(symbol=='/')
			result=number1/number2; symbol=='-' symbol '-' result=number1-number2 result number1-number2 number1 number2 if(symbol=='*')
			result=number1*number2;
		else if(symbol=='/')
			result=number1/number2; symbol=='*' symbol '*' result=number1*number2 result number1*number2 number1 number2 if(symbol=='/')
			result=number1/number2; symbol=='/' symbol '/' result=number1/number2 result number1/number2 number1 number2 return result; result int number1 number1 int number2 number2 char symbol symbol


import java.util.*;

class Main {
	public static void main(String[] args){
		Scanner input=new Scanner(System.in);
		
		Stack<Integer> stack=new Stack<Integer>();
		
		String expression=input.nextLine();
		
		String[] arrays=expression.split(" ");
		
		for(int i=0;i<arrays.length;i++){
			if(Character.isDigit(arrays[i].charAt(0)))
				stack.add(Integer.parseInt(arrays[i]));
			else if(!Character.isDigit(arrays[i].charAt(0))){
				int number2=stack.pop();
				int number1=stack.pop();
				
				stack.push(add(number1,number2,arrays[i].charAt(0)));
			}
				
		}
		
		System.out.println(stack.pop());
		
		
	}
	
	public static int add(int number1,int number2,char symbol){
		int result=0;
		if(symbol=='+')
			result=number1+number2;
		else if(symbol=='-')
			result=number1-number2;
		else if(symbol=='*')
			result=number1*number2;
		else if(symbol=='/')
			result=number1/number2;
		
		
		return result;
	}

}