import java.util.*;

public class Main {
       
    
    public static void main(String[] args){                
        Scanner input = new Scanner(System.in);
        String grab;
        Stack<Integer> stack = new Stack<Integer>();
        while (input.hasNext()) {                        
            grab = input.next();
            
            if (Character.isDigit(grab.charAt(0))) {
            stack.push(Integer.parseInt(grab));
            }//if
            else {
                int a = stack.pop();
                int b = stack.pop();
                if (grab.equals("+")){
                    stack.push(a + b);
                }//if 
                if (grab.equals("-")){ 
                stack.push(b - a);
                }//if
                if (grab.equals("*")){
                stack.push(b * a);
                }//if
            }//else
        }//while
        System.out.println(stack.pop());
    }//main            
}//Main

 import java.util.*; util.* java public class Main {
       
    
    public static void main(String[] args){                
        Scanner input = new Scanner(System.in);
        String grab;
        Stack<Integer> stack = new Stack<Integer>();
        while (input.hasNext()) {                        
            grab = input.next();
            
            if (Character.isDigit(grab.charAt(0))) {
            stack.push(Integer.parseInt(grab));
            }//if
            else {
                int a = stack.pop();
                int b = stack.pop();
                if (grab.equals("+")){
                    stack.push(a + b);
                }//if 
                if (grab.equals("-")){ 
                stack.push(b - a);
                }//if
                if (grab.equals("*")){
                stack.push(b * a);
                }//if
            }//else
        }//while
        System.out.println(stack.pop());
    }//main            
}//Main Main public static void main(String[] args){                
        Scanner input = new Scanner(System.in);
        String grab;
        Stack<Integer> stack = new Stack<Integer>();
        while (input.hasNext()) {                        
            grab = input.next();
            
            if (Character.isDigit(grab.charAt(0))) {
            stack.push(Integer.parseInt(grab));
            }//if
            else {
                int a = stack.pop();
                int b = stack.pop();
                if (grab.equals("+")){
                    stack.push(a + b);
                }//if 
                if (grab.equals("-")){ 
                stack.push(b - a);
                }//if
                if (grab.equals("*")){
                stack.push(b * a);
                }//if
            }//else
        }//while
        System.out.println(stack.pop());
    }//main             main {                
        Scanner input = new Scanner(System.in);
        String grab;
        Stack<Integer> stack = new Stack<Integer>();
        while (input.hasNext()) {                        
            grab = input.next();
            
            if (Character.isDigit(grab.charAt(0))) {
            stack.push(Integer.parseInt(grab));
            }//if
            else {
                int a = stack.pop();
                int b = stack.pop();
                if (grab.equals("+")){
                    stack.push(a + b);
                }//if 
                if (grab.equals("-")){ 
                stack.push(b - a);
                }//if
                if (grab.equals("*")){
                stack.push(b * a);
                }//if
            }//else
        }//while
        System.out.println(stack.pop());
    } Scanner input = new Scanner(System.in); input new Scanner(System.in) String grab; grab Stack<Integer> stack = new Stack<Integer>(); stack new Stack<Integer>() while (input.hasNext()) {                        
            grab = input.next();
            
            if (Character.isDigit(grab.charAt(0))) {
            stack.push(Integer.parseInt(grab));
            }//if
            else {
                int a = stack.pop();
                int b = stack.pop();
                if (grab.equals("+")){
                    stack.push(a + b);
                }//if 
                if (grab.equals("-")){ 
                stack.push(b - a);
                }//if
                if (grab.equals("*")){
                stack.push(b * a);
                }//if
            }//else
        }//while input.hasNext() input.hasNext input {                        
            grab = input.next();
            
            if (Character.isDigit(grab.charAt(0))) {
            stack.push(Integer.parseInt(grab));
            }//if
            else {
                int a = stack.pop();
                int b = stack.pop();
                if (grab.equals("+")){
                    stack.push(a + b);
                }//if 
                if (grab.equals("-")){ 
                stack.push(b - a);
                }//if
                if (grab.equals("*")){
                stack.push(b * a);
                }//if
            }//else
        } grab = input.next() grab input.next() input.next input if (Character.isDigit(grab.charAt(0))) {
            stack.push(Integer.parseInt(grab));
            }//if
            else {
                int a = stack.pop();
                int b = stack.pop();
                if (grab.equals("+")){
                    stack.push(a + b);
                }//if 
                if (grab.equals("-")){ 
                stack.push(b - a);
                }//if
                if (grab.equals("*")){
                stack.push(b * a);
                }//if
            }//else Character.isDigit(grab.charAt(0)) Character.isDigit Character grab.charAt(0) grab.charAt grab 0 {
            stack.push(Integer.parseInt(grab));
            } stack.push(Integer.parseInt(grab)) stack.push stack Integer.parseInt(grab) Integer.parseInt Integer grab {
                int a = stack.pop();
                int b = stack.pop();
                if (grab.equals("+")){
                    stack.push(a + b);
                }//if 
                if (grab.equals("-")){ 
                stack.push(b - a);
                }//if
                if (grab.equals("*")){
                stack.push(b * a);
                }//if
            } int a = stack.pop(); a stack.pop() stack.pop stack int b = stack.pop(); b stack.pop() stack.pop stack if (grab.equals("+")){
                    stack.push(a + b);
                }//if  grab.equals("+") grab.equals grab "+" {
                    stack.push(a + b);
                } stack.push(a + b) stack.push stack a + b a b if (grab.equals("-")){ 
                stack.push(b - a);
                }//if grab.equals("-") grab.equals grab "-" { 
                stack.push(b - a);
                } stack.push(b - a) stack.push stack b - a b a if (grab.equals("*")){
                stack.push(b * a);
                }//if grab.equals("*") grab.equals grab "*" {
                stack.push(b * a);
                } stack.push(b * a) stack.push stack b * a b a System.out.println(stack.pop()) System.out.println System.out System System.out stack.pop() stack.pop stack String[] args args public class Main {
       
    
    public static void main(String[] args){                
        Scanner input = new Scanner(System.in);
        String grab;
        Stack<Integer> stack = new Stack<Integer>();
        while (input.hasNext()) {                        
            grab = input.next();
            
            if (Character.isDigit(grab.charAt(0))) {
            stack.push(Integer.parseInt(grab));
            }//if
            else {
                int a = stack.pop();
                int b = stack.pop();
                if (grab.equals("+")){
                    stack.push(a + b);
                }//if 
                if (grab.equals("-")){ 
                stack.push(b - a);
                }//if
                if (grab.equals("*")){
                stack.push(b * a);
                }//if
            }//else
        }//while
        System.out.println(stack.pop());
    }//main            
}//Main public class Main {
       
    
    public static void main(String[] args){                
        Scanner input = new Scanner(System.in);
        String grab;
        Stack<Integer> stack = new Stack<Integer>();
        while (input.hasNext()) {                        
            grab = input.next();
            
            if (Character.isDigit(grab.charAt(0))) {
            stack.push(Integer.parseInt(grab));
            }//if
            else {
                int a = stack.pop();
                int b = stack.pop();
                if (grab.equals("+")){
                    stack.push(a + b);
                }//if 
                if (grab.equals("-")){ 
                stack.push(b - a);
                }//if
                if (grab.equals("*")){
                stack.push(b * a);
                }//if
            }//else
        }//while
        System.out.println(stack.pop());
    }//main            
}//Main Main
import java.util.*;

public class Main {
       
    
    public static void main(String[] args){                
        Scanner input = new Scanner(System.in);
        String grab;
        Stack<Integer> stack = new Stack<Integer>();
        while (input.hasNext()) {                        
            grab = input.next();
            
            if (Character.isDigit(grab.charAt(0))) {
            stack.push(Integer.parseInt(grab));
            }//if
            else {
                int a = stack.pop();
                int b = stack.pop();
                if (grab.equals("+")){
                    stack.push(a + b);
                }//if 
                if (grab.equals("-")){ 
                stack.push(b - a);
                }//if
                if (grab.equals("*")){
                stack.push(b * a);
                }//if
            }//else
        }//while
        System.out.println(stack.pop());
    }//main            
}//Main


