import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    static final int INF = 1000000000;     
    
    public static void main(String[] args) throws Exception {                
        Scanner input = new Scanner(System.in);
        String st;
        Stack<Integer> stack = new Stack<Integer>();
        while (input.hasNext()) {                        
            st = input.next();
            if (Character.isDigit(st.charAt(0))) stack.push(Integer.parseInt(st));
            else {
                int x = stack.pop();
                int y = stack.pop();
                if (st.equals("+")) stack.push(x + y);
                else if (st.equals("-")) stack.push(y - x);
                else if (st.equals("*")) stack.push(y * x);
            }
        }
        System.out.println(stack.pop());
    }            
} import java.util.*; util.* java import java.io.*; io.* java import java.lang.*; lang.* java public class Main {
    static final int INF = 1000000000;     
    
    public static void main(String[] args) throws Exception {                
        Scanner input = new Scanner(System.in);
        String st;
        Stack<Integer> stack = new Stack<Integer>();
        while (input.hasNext()) {                        
            st = input.next();
            if (Character.isDigit(st.charAt(0))) stack.push(Integer.parseInt(st));
            else {
                int x = stack.pop();
                int y = stack.pop();
                if (st.equals("+")) stack.push(x + y);
                else if (st.equals("-")) stack.push(y - x);
                else if (st.equals("*")) stack.push(y * x);
            }
        }
        System.out.println(stack.pop());
    }            
} Main static final int INF = 1000000000; INF 1000000000 public static void main(String[] args) throws Exception {                
        Scanner input = new Scanner(System.in);
        String st;
        Stack<Integer> stack = new Stack<Integer>();
        while (input.hasNext()) {                        
            st = input.next();
            if (Character.isDigit(st.charAt(0))) stack.push(Integer.parseInt(st));
            else {
                int x = stack.pop();
                int y = stack.pop();
                if (st.equals("+")) stack.push(x + y);
                else if (st.equals("-")) stack.push(y - x);
                else if (st.equals("*")) stack.push(y * x);
            }
        }
        System.out.println(stack.pop());
    } main {                
        Scanner input = new Scanner(System.in);
        String st;
        Stack<Integer> stack = new Stack<Integer>();
        while (input.hasNext()) {                        
            st = input.next();
            if (Character.isDigit(st.charAt(0))) stack.push(Integer.parseInt(st));
            else {
                int x = stack.pop();
                int y = stack.pop();
                if (st.equals("+")) stack.push(x + y);
                else if (st.equals("-")) stack.push(y - x);
                else if (st.equals("*")) stack.push(y * x);
            }
        }
        System.out.println(stack.pop());
    } Scanner input = new Scanner(System.in); input new Scanner(System.in) String st; st Stack<Integer> stack = new Stack<Integer>(); stack new Stack<Integer>() while (input.hasNext()) {                        
            st = input.next();
            if (Character.isDigit(st.charAt(0))) stack.push(Integer.parseInt(st));
            else {
                int x = stack.pop();
                int y = stack.pop();
                if (st.equals("+")) stack.push(x + y);
                else if (st.equals("-")) stack.push(y - x);
                else if (st.equals("*")) stack.push(y * x);
            }
        } input.hasNext() input.hasNext input {                        
            st = input.next();
            if (Character.isDigit(st.charAt(0))) stack.push(Integer.parseInt(st));
            else {
                int x = stack.pop();
                int y = stack.pop();
                if (st.equals("+")) stack.push(x + y);
                else if (st.equals("-")) stack.push(y - x);
                else if (st.equals("*")) stack.push(y * x);
            }
        } st = input.next() st input.next() input.next input if (Character.isDigit(st.charAt(0))) stack.push(Integer.parseInt(st));
            else {
                int x = stack.pop();
                int y = stack.pop();
                if (st.equals("+")) stack.push(x + y);
                else if (st.equals("-")) stack.push(y - x);
                else if (st.equals("*")) stack.push(y * x);
            } Character.isDigit(st.charAt(0)) Character.isDigit Character st.charAt(0) st.charAt st 0 stack.push(Integer.parseInt(st)) stack.push stack Integer.parseInt(st) Integer.parseInt Integer st {
                int x = stack.pop();
                int y = stack.pop();
                if (st.equals("+")) stack.push(x + y);
                else if (st.equals("-")) stack.push(y - x);
                else if (st.equals("*")) stack.push(y * x);
            } int x = stack.pop(); x stack.pop() stack.pop stack int y = stack.pop(); y stack.pop() stack.pop stack if (st.equals("+")) stack.push(x + y);
                else if (st.equals("-")) stack.push(y - x);
                else if (st.equals("*")) stack.push(y * x); st.equals("+") st.equals st "+" stack.push(x + y) stack.push stack x + y x y if (st.equals("-")) stack.push(y - x);
                else if (st.equals("*")) stack.push(y * x); st.equals("-") st.equals st "-" stack.push(y - x) stack.push stack y - x y x if (st.equals("*")) stack.push(y * x); st.equals("*") st.equals st "*" stack.push(y * x) stack.push stack y * x y x System.out.println(stack.pop()) System.out.println System.out System System.out stack.pop() stack.pop stack String[] args args public class Main {
    static final int INF = 1000000000;     
    
    public static void main(String[] args) throws Exception {                
        Scanner input = new Scanner(System.in);
        String st;
        Stack<Integer> stack = new Stack<Integer>();
        while (input.hasNext()) {                        
            st = input.next();
            if (Character.isDigit(st.charAt(0))) stack.push(Integer.parseInt(st));
            else {
                int x = stack.pop();
                int y = stack.pop();
                if (st.equals("+")) stack.push(x + y);
                else if (st.equals("-")) stack.push(y - x);
                else if (st.equals("*")) stack.push(y * x);
            }
        }
        System.out.println(stack.pop());
    }            
} public class Main {
    static final int INF = 1000000000;     
    
    public static void main(String[] args) throws Exception {                
        Scanner input = new Scanner(System.in);
        String st;
        Stack<Integer> stack = new Stack<Integer>();
        while (input.hasNext()) {                        
            st = input.next();
            if (Character.isDigit(st.charAt(0))) stack.push(Integer.parseInt(st));
            else {
                int x = stack.pop();
                int y = stack.pop();
                if (st.equals("+")) stack.push(x + y);
                else if (st.equals("-")) stack.push(y - x);
                else if (st.equals("*")) stack.push(y * x);
            }
        }
        System.out.println(stack.pop());
    }            
} Main
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    static final int INF = 1000000000;     
    
    public static void main(String[] args) throws Exception {                
        Scanner input = new Scanner(System.in);
        String st;
        Stack<Integer> stack = new Stack<Integer>();
        while (input.hasNext()) {                        
            st = input.next();
            if (Character.isDigit(st.charAt(0))) stack.push(Integer.parseInt(st));
            else {
                int x = stack.pop();
                int y = stack.pop();
                if (st.equals("+")) stack.push(x + y);
                else if (st.equals("-")) stack.push(y - x);
                else if (st.equals("*")) stack.push(y * x);
            }
        }
        System.out.println(stack.pop());
    }            
}