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

public class Main {

    public static void main(String args[]) throws IOException {
    	
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] inputArray = br.readLine().split(" ");
        
        Stack<Integer> stack = new Stack<Integer>();
        int a = 0;
        int b = 0;
        
        for (int i = 0; i < inputArray.length; i++) {
            if (inputArray[i].equals("+")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b + a);
                continue;
            }
            
            if (inputArray[i].equals("-")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b - a);
                continue;
            }
            
            if (inputArray[i].equals("*")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b * a);
                continue;
            }
            
            stack.push(Integer.parseInt(inputArray[i]));
        }
        System.out.println(stack.pop());
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Stack; Stack java.util public class Main {

    public static void main(String args[]) throws IOException {
    	
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] inputArray = br.readLine().split(" ");
        
        Stack<Integer> stack = new Stack<Integer>();
        int a = 0;
        int b = 0;
        
        for (int i = 0; i < inputArray.length; i++) {
            if (inputArray[i].equals("+")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b + a);
                continue;
            }
            
            if (inputArray[i].equals("-")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b - a);
                continue;
            }
            
            if (inputArray[i].equals("*")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b * a);
                continue;
            }
            
            stack.push(Integer.parseInt(inputArray[i]));
        }
        System.out.println(stack.pop());
    }
} Main public static void main(String args[]) throws IOException {
    	
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] inputArray = br.readLine().split(" ");
        
        Stack<Integer> stack = new Stack<Integer>();
        int a = 0;
        int b = 0;
        
        for (int i = 0; i < inputArray.length; i++) {
            if (inputArray[i].equals("+")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b + a);
                continue;
            }
            
            if (inputArray[i].equals("-")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b - a);
                continue;
            }
            
            if (inputArray[i].equals("*")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b * a);
                continue;
            }
            
            stack.push(Integer.parseInt(inputArray[i]));
        }
        System.out.println(stack.pop());
    } main {
    	
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] inputArray = br.readLine().split(" ");
        
        Stack<Integer> stack = new Stack<Integer>();
        int a = 0;
        int b = 0;
        
        for (int i = 0; i < inputArray.length; i++) {
            if (inputArray[i].equals("+")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b + a);
                continue;
            }
            
            if (inputArray[i].equals("-")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b - a);
                continue;
            }
            
            if (inputArray[i].equals("*")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b * a);
                continue;
            }
            
            stack.push(Integer.parseInt(inputArray[i]));
        }
        System.out.println(stack.pop());
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] inputArray = br.readLine().split(" "); inputArray br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " Stack<Integer> stack = new Stack<Integer>(); stack new Stack<Integer>() int a = 0; a 0 int b = 0; b 0 for (int i = 0; i < inputArray.length; i++) {
            if (inputArray[i].equals("+")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b + a);
                continue;
            }
            
            if (inputArray[i].equals("-")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b - a);
                continue;
            }
            
            if (inputArray[i].equals("*")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b * a);
                continue;
            }
            
            stack.push(Integer.parseInt(inputArray[i]));
        } int i = 0; int i = 0; i 0 i < inputArray.length i inputArray.length inputArray inputArray.length i++ i++ i {
            if (inputArray[i].equals("+")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b + a);
                continue;
            }
            
            if (inputArray[i].equals("-")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b - a);
                continue;
            }
            
            if (inputArray[i].equals("*")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b * a);
                continue;
            }
            
            stack.push(Integer.parseInt(inputArray[i]));
        } {
            if (inputArray[i].equals("+")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b + a);
                continue;
            }
            
            if (inputArray[i].equals("-")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b - a);
                continue;
            }
            
            if (inputArray[i].equals("*")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b * a);
                continue;
            }
            
            stack.push(Integer.parseInt(inputArray[i]));
        } if (inputArray[i].equals("+")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b + a);
                continue;
            } inputArray[i].equals("+") inputArray[i].equals inputArray[i] inputArray i "+" {
                a = stack.pop();
                b = stack.pop();
                stack.add(b + a);
                continue;
            } a = stack.pop() a stack.pop() stack.pop stack b = stack.pop() b stack.pop() stack.pop stack stack.add(b + a) stack.add stack b + a b a continue; if (inputArray[i].equals("-")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b - a);
                continue;
            } inputArray[i].equals("-") inputArray[i].equals inputArray[i] inputArray i "-" {
                a = stack.pop();
                b = stack.pop();
                stack.add(b - a);
                continue;
            } a = stack.pop() a stack.pop() stack.pop stack b = stack.pop() b stack.pop() stack.pop stack stack.add(b - a) stack.add stack b - a b a continue; if (inputArray[i].equals("*")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b * a);
                continue;
            } inputArray[i].equals("*") inputArray[i].equals inputArray[i] inputArray i "*" {
                a = stack.pop();
                b = stack.pop();
                stack.add(b * a);
                continue;
            } a = stack.pop() a stack.pop() stack.pop stack b = stack.pop() b stack.pop() stack.pop stack stack.add(b * a) stack.add stack b * a b a continue; stack.push(Integer.parseInt(inputArray[i])) stack.push stack Integer.parseInt(inputArray[i]) Integer.parseInt Integer inputArray[i] inputArray i 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[]) throws IOException {
    	
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] inputArray = br.readLine().split(" ");
        
        Stack<Integer> stack = new Stack<Integer>();
        int a = 0;
        int b = 0;
        
        for (int i = 0; i < inputArray.length; i++) {
            if (inputArray[i].equals("+")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b + a);
                continue;
            }
            
            if (inputArray[i].equals("-")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b - a);
                continue;
            }
            
            if (inputArray[i].equals("*")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b * a);
                continue;
            }
            
            stack.push(Integer.parseInt(inputArray[i]));
        }
        System.out.println(stack.pop());
    }
} public class Main {

    public static void main(String args[]) throws IOException {
    	
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] inputArray = br.readLine().split(" ");
        
        Stack<Integer> stack = new Stack<Integer>();
        int a = 0;
        int b = 0;
        
        for (int i = 0; i < inputArray.length; i++) {
            if (inputArray[i].equals("+")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b + a);
                continue;
            }
            
            if (inputArray[i].equals("-")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b - a);
                continue;
            }
            
            if (inputArray[i].equals("*")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b * a);
                continue;
            }
            
            stack.push(Integer.parseInt(inputArray[i]));
        }
        System.out.println(stack.pop());
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;

public class Main {

    public static void main(String args[]) throws IOException {
    	
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] inputArray = br.readLine().split(" ");
        
        Stack<Integer> stack = new Stack<Integer>();
        int a = 0;
        int b = 0;
        
        for (int i = 0; i < inputArray.length; i++) {
            if (inputArray[i].equals("+")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b + a);
                continue;
            }
            
            if (inputArray[i].equals("-")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b - a);
                continue;
            }
            
            if (inputArray[i].equals("*")) {
                a = stack.pop();
                b = stack.pop();
                stack.add(b * a);
                continue;
            }
            
            stack.push(Integer.parseInt(inputArray[i]));
        }
        System.out.println(stack.pop());
    }
}
