
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;


public class Main {
    
    public static void main(String[] args) throws IOException {
        Deque<Long> stack = new ArrayDeque<>();
        BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
        
        String s = buf.readLine();
        String[] splited = s.split(" ", 0);
      
        //????????????????????¨??£?????????.(?¨?????????????second op first)??¨???
        long first;
        long second;
        for (String currentString : splited) {
            if ("+".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second + first));
            } else if ("-".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second - first));               
            } else if ("*".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second * first));            
            } else if ("/".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second / first));
            } else {
                stack.addFirst(Long.parseLong(currentString));
            }
        }
        System.out.println(stack.removeFirst());
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayDeque; ArrayDeque java.util import java.util.Deque; Deque java.util public class Main {
    
    public static void main(String[] args) throws IOException {
        Deque<Long> stack = new ArrayDeque<>();
        BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
        
        String s = buf.readLine();
        String[] splited = s.split(" ", 0);
      
        //????????????????????¨??£?????????.(?¨?????????????second op first)??¨???
        long first;
        long second;
        for (String currentString : splited) {
            if ("+".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second + first));
            } else if ("-".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second - first));               
            } else if ("*".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second * first));            
            } else if ("/".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second / first));
            } else {
                stack.addFirst(Long.parseLong(currentString));
            }
        }
        System.out.println(stack.removeFirst());
    }
} Main public static void main(String[] args) throws IOException {
        Deque<Long> stack = new ArrayDeque<>();
        BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
        
        String s = buf.readLine();
        String[] splited = s.split(" ", 0);
      
        //????????????????????¨??£?????????.(?¨?????????????second op first)??¨???
        long first;
        long second;
        for (String currentString : splited) {
            if ("+".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second + first));
            } else if ("-".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second - first));               
            } else if ("*".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second * first));            
            } else if ("/".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second / first));
            } else {
                stack.addFirst(Long.parseLong(currentString));
            }
        }
        System.out.println(stack.removeFirst());
    } main {
        Deque<Long> stack = new ArrayDeque<>();
        BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
        
        String s = buf.readLine();
        String[] splited = s.split(" ", 0);
      
        //????????????????????¨??£?????????.(?¨?????????????second op first)??¨???
        long first;
        long second;
        for (String currentString : splited) {
            if ("+".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second + first));
            } else if ("-".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second - first));               
            } else if ("*".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second * first));            
            } else if ("/".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second / first));
            } else {
                stack.addFirst(Long.parseLong(currentString));
            }
        }
        System.out.println(stack.removeFirst());
    } Deque<Long> stack = new ArrayDeque<>(); stack new ArrayDeque<>() BufferedReader buf = new BufferedReader(new InputStreamReader(System.in)); buf new BufferedReader(new InputStreamReader(System.in)) String s = buf.readLine(); s buf.readLine() buf.readLine buf String[] splited = s.split(" ", 0); splited s.split(" ", 0) s.split s " " 0 long first; first long second; second for (String currentString : splited) {
            if ("+".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second + first));
            } else if ("-".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second - first));               
            } else if ("*".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second * first));            
            } else if ("/".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second / first));
            } else {
                stack.addFirst(Long.parseLong(currentString));
            }
        } String currentString splited {
            if ("+".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second + first));
            } else if ("-".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second - first));               
            } else if ("*".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second * first));            
            } else if ("/".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second / first));
            } else {
                stack.addFirst(Long.parseLong(currentString));
            }
        } {
            if ("+".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second + first));
            } else if ("-".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second - first));               
            } else if ("*".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second * first));            
            } else if ("/".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second / first));
            } else {
                stack.addFirst(Long.parseLong(currentString));
            }
        } if ("+".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second + first));
            } else if ("-".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second - first));               
            } else if ("*".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second * first));            
            } else if ("/".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second / first));
            } else {
                stack.addFirst(Long.parseLong(currentString));
            } "+".equals(currentString) "+".equals "+" currentString {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second + first));
            } first = stack.removeFirst() first stack.removeFirst() stack.removeFirst stack second = stack.removeFirst() second stack.removeFirst() stack.removeFirst stack stack.addFirst((second + first)) stack.addFirst stack (second + first) second first if ("-".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second - first));               
            } else if ("*".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second * first));            
            } else if ("/".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second / first));
            } else {
                stack.addFirst(Long.parseLong(currentString));
            } "-".equals(currentString) "-".equals "-" currentString {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second - first));               
            } first = stack.removeFirst() first stack.removeFirst() stack.removeFirst stack second = stack.removeFirst() second stack.removeFirst() stack.removeFirst stack stack.addFirst((second - first)) stack.addFirst stack (second - first) second first if ("*".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second * first));            
            } else if ("/".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second / first));
            } else {
                stack.addFirst(Long.parseLong(currentString));
            } "*".equals(currentString) "*".equals "*" currentString {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second * first));            
            } first = stack.removeFirst() first stack.removeFirst() stack.removeFirst stack second = stack.removeFirst() second stack.removeFirst() stack.removeFirst stack stack.addFirst((second * first)) stack.addFirst stack (second * first) second first if ("/".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second / first));
            } else {
                stack.addFirst(Long.parseLong(currentString));
            } "/".equals(currentString) "/".equals "/" currentString {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second / first));
            } first = stack.removeFirst() first stack.removeFirst() stack.removeFirst stack second = stack.removeFirst() second stack.removeFirst() stack.removeFirst stack stack.addFirst((second / first)) stack.addFirst stack (second / first) second first {
                stack.addFirst(Long.parseLong(currentString));
            } stack.addFirst(Long.parseLong(currentString)) stack.addFirst stack Long.parseLong(currentString) Long.parseLong Long currentString System.out.println(stack.removeFirst()) System.out.println System.out System System.out stack.removeFirst() stack.removeFirst stack String[] args args public class Main {
    
    public static void main(String[] args) throws IOException {
        Deque<Long> stack = new ArrayDeque<>();
        BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
        
        String s = buf.readLine();
        String[] splited = s.split(" ", 0);
      
        //????????????????????¨??£?????????.(?¨?????????????second op first)??¨???
        long first;
        long second;
        for (String currentString : splited) {
            if ("+".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second + first));
            } else if ("-".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second - first));               
            } else if ("*".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second * first));            
            } else if ("/".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second / first));
            } else {
                stack.addFirst(Long.parseLong(currentString));
            }
        }
        System.out.println(stack.removeFirst());
    }
} public class Main {
    
    public static void main(String[] args) throws IOException {
        Deque<Long> stack = new ArrayDeque<>();
        BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
        
        String s = buf.readLine();
        String[] splited = s.split(" ", 0);
      
        //????????????????????¨??£?????????.(?¨?????????????second op first)??¨???
        long first;
        long second;
        for (String currentString : splited) {
            if ("+".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second + first));
            } else if ("-".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second - first));               
            } else if ("*".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second * first));            
            } else if ("/".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second / first));
            } else {
                stack.addFirst(Long.parseLong(currentString));
            }
        }
        System.out.println(stack.removeFirst());
    }
} Main

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;


public class Main {
    
    public static void main(String[] args) throws IOException {
        Deque<Long> stack = new ArrayDeque<>();
        BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
        
        String s = buf.readLine();
        String[] splited = s.split(" ", 0);
      
        //????????????????????¨??£?????????.(?¨?????????????second op first)??¨???
        long first;
        long second;
        for (String currentString : splited) {
            if ("+".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second + first));
            } else if ("-".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second - first));               
            } else if ("*".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second * first));            
            } else if ("/".equals(currentString)) {
                first = stack.removeFirst();
                second = stack.removeFirst();
                stack.addFirst((second / first));
            } else {
                stack.addFirst(Long.parseLong(currentString));
            }
        }
        System.out.println(stack.removeFirst());
    }
}