import java.util.Scanner;
import java.util.Stack;

public class Main{ // algorithm for reverse polish notation

	
	
	
	  
    public static void main(String[] args) {
    	 Scanner sc = new Scanner(System.in);
         String ex = sc.nextLine();
         String[] k = ex.split(" ");
    String[] polish = k;
    String testCase = "";
    int testSize = polish.length; // length of the test case
    int number1=0;
    int number2=0;
    Stack<Integer> stack = new Stack<Integer>();
   
    for(int i=0; i<testSize; i++){
   	 testCase = polish[i];

        
        if(testCase.equals("+") || testCase.equals("-") || testCase.equals("*") || testCase.equals("/")) {
            number2 = (int) stack.pop();
            number1 = (int) stack.pop();
            
            switch(testCase){
            case "+" :
                stack.push(number1+number2); // plus
                break;
            case "-" :
                stack.push(number1-number2); // minus
                break;
            case "*" :
                stack.push(number1*number2); // multiplication
                break;
            case "/" :
                stack.push(number1/number2); // division
                break;
            }
        }else{
            stack.push(Integer.parseInt(testCase));
        }
        
        
          
    }
    System.out.println(stack.pop());
    
  
}
    	
    	
    
    	
          
           
            
            
        
        
       



}
 import java.util.Scanner; Scanner java.util import java.util.Stack; Stack java.util public class Main{ // algorithm for reverse polish notation

	
	
	
	  
    public static void main(String[] args) {
    	 Scanner sc = new Scanner(System.in);
         String ex = sc.nextLine();
         String[] k = ex.split(" ");
    String[] polish = k;
    String testCase = "";
    int testSize = polish.length; // length of the test case
    int number1=0;
    int number2=0;
    Stack<Integer> stack = new Stack<Integer>();
   
    for(int i=0; i<testSize; i++){
   	 testCase = polish[i];

        
        if(testCase.equals("+") || testCase.equals("-") || testCase.equals("*") || testCase.equals("/")) {
            number2 = (int) stack.pop();
            number1 = (int) stack.pop();
            
            switch(testCase){
            case "+" :
                stack.push(number1+number2); // plus
                break;
            case "-" :
                stack.push(number1-number2); // minus
                break;
            case "*" :
                stack.push(number1*number2); // multiplication
                break;
            case "/" :
                stack.push(number1/number2); // division
                break;
            }
        }else{
            stack.push(Integer.parseInt(testCase));
        }
        
        
          
    }
    System.out.println(stack.pop());
    
  
}
    	
    	
    
    	
          
           
            
            
        
        
       



} Main public static void main(String[] args) {
    	 Scanner sc = new Scanner(System.in);
         String ex = sc.nextLine();
         String[] k = ex.split(" ");
    String[] polish = k;
    String testCase = "";
    int testSize = polish.length; // length of the test case
    int number1=0;
    int number2=0;
    Stack<Integer> stack = new Stack<Integer>();
   
    for(int i=0; i<testSize; i++){
   	 testCase = polish[i];

        
        if(testCase.equals("+") || testCase.equals("-") || testCase.equals("*") || testCase.equals("/")) {
            number2 = (int) stack.pop();
            number1 = (int) stack.pop();
            
            switch(testCase){
            case "+" :
                stack.push(number1+number2); // plus
                break;
            case "-" :
                stack.push(number1-number2); // minus
                break;
            case "*" :
                stack.push(number1*number2); // multiplication
                break;
            case "/" :
                stack.push(number1/number2); // division
                break;
            }
        }else{
            stack.push(Integer.parseInt(testCase));
        }
        
        
          
    }
    System.out.println(stack.pop());
    
  
} main {
    	 Scanner sc = new Scanner(System.in);
         String ex = sc.nextLine();
         String[] k = ex.split(" ");
    String[] polish = k;
    String testCase = "";
    int testSize = polish.length; // length of the test case
    int number1=0;
    int number2=0;
    Stack<Integer> stack = new Stack<Integer>();
   
    for(int i=0; i<testSize; i++){
   	 testCase = polish[i];

        
        if(testCase.equals("+") || testCase.equals("-") || testCase.equals("*") || testCase.equals("/")) {
            number2 = (int) stack.pop();
            number1 = (int) stack.pop();
            
            switch(testCase){
            case "+" :
                stack.push(number1+number2); // plus
                break;
            case "-" :
                stack.push(number1-number2); // minus
                break;
            case "*" :
                stack.push(number1*number2); // multiplication
                break;
            case "/" :
                stack.push(number1/number2); // division
                break;
            }
        }else{
            stack.push(Integer.parseInt(testCase));
        }
        
        
          
    }
    System.out.println(stack.pop());
    
  
} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String ex = sc.nextLine(); ex sc.nextLine() sc.nextLine sc String[] k = ex.split(" "); k ex.split(" ") ex.split ex " " String[] polish = k; polish k String testCase = ""; testCase "" int testSize = polish.length; testSize polish.length polish polish.length int number1=0; number1 0 int number2=0; number2 0 Stack<Integer> stack = new Stack<Integer>(); stack new Stack<Integer>() for(int i=0; i<testSize; i++){
   	 testCase = polish[i];

        
        if(testCase.equals("+") || testCase.equals("-") || testCase.equals("*") || testCase.equals("/")) {
            number2 = (int) stack.pop();
            number1 = (int) stack.pop();
            
            switch(testCase){
            case "+" :
                stack.push(number1+number2); // plus
                break;
            case "-" :
                stack.push(number1-number2); // minus
                break;
            case "*" :
                stack.push(number1*number2); // multiplication
                break;
            case "/" :
                stack.push(number1/number2); // division
                break;
            }
        }else{
            stack.push(Integer.parseInt(testCase));
        }
        
        
          
    } int i=0; int i=0; i 0 i<testSize i testSize i++ i++ i {
   	 testCase = polish[i];

        
        if(testCase.equals("+") || testCase.equals("-") || testCase.equals("*") || testCase.equals("/")) {
            number2 = (int) stack.pop();
            number1 = (int) stack.pop();
            
            switch(testCase){
            case "+" :
                stack.push(number1+number2); // plus
                break;
            case "-" :
                stack.push(number1-number2); // minus
                break;
            case "*" :
                stack.push(number1*number2); // multiplication
                break;
            case "/" :
                stack.push(number1/number2); // division
                break;
            }
        }else{
            stack.push(Integer.parseInt(testCase));
        }
        
        
          
    } {
   	 testCase = polish[i];

        
        if(testCase.equals("+") || testCase.equals("-") || testCase.equals("*") || testCase.equals("/")) {
            number2 = (int) stack.pop();
            number1 = (int) stack.pop();
            
            switch(testCase){
            case "+" :
                stack.push(number1+number2); // plus
                break;
            case "-" :
                stack.push(number1-number2); // minus
                break;
            case "*" :
                stack.push(number1*number2); // multiplication
                break;
            case "/" :
                stack.push(number1/number2); // division
                break;
            }
        }else{
            stack.push(Integer.parseInt(testCase));
        }
        
        
          
    } testCase = polish[i] testCase polish[i] polish i if(testCase.equals("+") || testCase.equals("-") || testCase.equals("*") || testCase.equals("/")) {
            number2 = (int) stack.pop();
            number1 = (int) stack.pop();
            
            switch(testCase){
            case "+" :
                stack.push(number1+number2); // plus
                break;
            case "-" :
                stack.push(number1-number2); // minus
                break;
            case "*" :
                stack.push(number1*number2); // multiplication
                break;
            case "/" :
                stack.push(number1/number2); // division
                break;
            }
        }else{
            stack.push(Integer.parseInt(testCase));
        } testCase.equals("+") || testCase.equals("-") || testCase.equals("*") || testCase.equals("/") testCase.equals("*") testCase.equals("+") || testCase.equals("-") || testCase.equals("*") || testCase.equals("/") testCase.equals("+") testCase.equals testCase "+" testCase.equals("-") testCase.equals testCase "-" testCase.equals("*") testCase.equals testCase "*" testCase.equals("/") testCase.equals testCase "/" {
            number2 = (int) stack.pop();
            number1 = (int) stack.pop();
            
            switch(testCase){
            case "+" :
                stack.push(number1+number2); // plus
                break;
            case "-" :
                stack.push(number1-number2); // minus
                break;
            case "*" :
                stack.push(number1*number2); // multiplication
                break;
            case "/" :
                stack.push(number1/number2); // division
                break;
            }
        } number2 = (int) stack.pop() number2 (int) stack.pop() stack.pop stack number1 = (int) stack.pop() number1 (int) stack.pop() stack.pop stack switch(testCase){
            case "+" :
                stack.push(number1+number2); // plus
                break;
            case "-" :
                stack.push(number1-number2); // minus
                break;
            case "*" :
                stack.push(number1*number2); // multiplication
                break;
            case "/" :
                stack.push(number1/number2); // division
                break;
            } testCase case "+" : "+" case "+" : stack.push(number1+number2) stack.push stack number1+number2 number1 number2 break; case "-" : "-" case "-" : stack.push(number1-number2) stack.push stack number1-number2 number1 number2 break; case "*" : "*" case "*" : stack.push(number1*number2) stack.push stack number1*number2 number1 number2 break; case "/" : "/" case "/" : stack.push(number1/number2) stack.push stack number1/number2 number1 number2 break; {
            stack.push(Integer.parseInt(testCase));
        } stack.push(Integer.parseInt(testCase)) stack.push stack Integer.parseInt(testCase) Integer.parseInt Integer testCase System.out.println(stack.pop()) System.out.println System.out System System.out stack.pop() stack.pop stack String[] args args public class Main{ // algorithm for reverse polish notation

	
	
	
	  
    public static void main(String[] args) {
    	 Scanner sc = new Scanner(System.in);
         String ex = sc.nextLine();
         String[] k = ex.split(" ");
    String[] polish = k;
    String testCase = "";
    int testSize = polish.length; // length of the test case
    int number1=0;
    int number2=0;
    Stack<Integer> stack = new Stack<Integer>();
   
    for(int i=0; i<testSize; i++){
   	 testCase = polish[i];

        
        if(testCase.equals("+") || testCase.equals("-") || testCase.equals("*") || testCase.equals("/")) {
            number2 = (int) stack.pop();
            number1 = (int) stack.pop();
            
            switch(testCase){
            case "+" :
                stack.push(number1+number2); // plus
                break;
            case "-" :
                stack.push(number1-number2); // minus
                break;
            case "*" :
                stack.push(number1*number2); // multiplication
                break;
            case "/" :
                stack.push(number1/number2); // division
                break;
            }
        }else{
            stack.push(Integer.parseInt(testCase));
        }
        
        
          
    }
    System.out.println(stack.pop());
    
  
}
    	
    	
    
    	
          
           
            
            
        
        
       



} public class Main{ // algorithm for reverse polish notation

	
	
	
	  
    public static void main(String[] args) {
    	 Scanner sc = new Scanner(System.in);
         String ex = sc.nextLine();
         String[] k = ex.split(" ");
    String[] polish = k;
    String testCase = "";
    int testSize = polish.length; // length of the test case
    int number1=0;
    int number2=0;
    Stack<Integer> stack = new Stack<Integer>();
   
    for(int i=0; i<testSize; i++){
   	 testCase = polish[i];

        
        if(testCase.equals("+") || testCase.equals("-") || testCase.equals("*") || testCase.equals("/")) {
            number2 = (int) stack.pop();
            number1 = (int) stack.pop();
            
            switch(testCase){
            case "+" :
                stack.push(number1+number2); // plus
                break;
            case "-" :
                stack.push(number1-number2); // minus
                break;
            case "*" :
                stack.push(number1*number2); // multiplication
                break;
            case "/" :
                stack.push(number1/number2); // division
                break;
            }
        }else{
            stack.push(Integer.parseInt(testCase));
        }
        
        
          
    }
    System.out.println(stack.pop());
    
  
}
    	
    	
    
    	
          
           
            
            
        
        
       



} Main
import java.util.Scanner;
import java.util.Stack;

public class Main{ // algorithm for reverse polish notation

	
	
	
	  
    public static void main(String[] args) {
    	 Scanner sc = new Scanner(System.in);
         String ex = sc.nextLine();
         String[] k = ex.split(" ");
    String[] polish = k;
    String testCase = "";
    int testSize = polish.length; // length of the test case
    int number1=0;
    int number2=0;
    Stack<Integer> stack = new Stack<Integer>();
   
    for(int i=0; i<testSize; i++){
   	 testCase = polish[i];

        
        if(testCase.equals("+") || testCase.equals("-") || testCase.equals("*") || testCase.equals("/")) {
            number2 = (int) stack.pop();
            number1 = (int) stack.pop();
            
            switch(testCase){
            case "+" :
                stack.push(number1+number2); // plus
                break;
            case "-" :
                stack.push(number1-number2); // minus
                break;
            case "*" :
                stack.push(number1*number2); // multiplication
                break;
            case "/" :
                stack.push(number1/number2); // division
                break;
            }
        }else{
            stack.push(Integer.parseInt(testCase));
        }
        
        
          
    }
    System.out.println(stack.pop());
    
  
}
    	
    	
    
    	
          
           
            
            
        
        
       



}

