import java.util.*;
public class Main {
    public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        Deque<Integer> Stack = new ArrayDeque<>();
        String S = sc.nextLine();
        String list [] = S.split(" ");
        for(int i=0;i<list.length;i++){
            S = list[i];
            if(S.equals("+")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n1+n2);
            }
            else if(S.equals("-")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n2-n1);
            }
            else if(S.equals("*")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n1*n2);
            }
            else Stack.push(Integer.parseInt(S));
        }
        System.out.println(Stack.pop());
    }
} import java.util.*; util.* java public class Main {
    public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        Deque<Integer> Stack = new ArrayDeque<>();
        String S = sc.nextLine();
        String list [] = S.split(" ");
        for(int i=0;i<list.length;i++){
            S = list[i];
            if(S.equals("+")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n1+n2);
            }
            else if(S.equals("-")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n2-n1);
            }
            else if(S.equals("*")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n1*n2);
            }
            else Stack.push(Integer.parseInt(S));
        }
        System.out.println(Stack.pop());
    }
} Main public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        Deque<Integer> Stack = new ArrayDeque<>();
        String S = sc.nextLine();
        String list [] = S.split(" ");
        for(int i=0;i<list.length;i++){
            S = list[i];
            if(S.equals("+")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n1+n2);
            }
            else if(S.equals("-")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n2-n1);
            }
            else if(S.equals("*")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n1*n2);
            }
            else Stack.push(Integer.parseInt(S));
        }
        System.out.println(Stack.pop());
    } main {
        Scanner sc = new Scanner(System.in);
        Deque<Integer> Stack = new ArrayDeque<>();
        String S = sc.nextLine();
        String list [] = S.split(" ");
        for(int i=0;i<list.length;i++){
            S = list[i];
            if(S.equals("+")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n1+n2);
            }
            else if(S.equals("-")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n2-n1);
            }
            else if(S.equals("*")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n1*n2);
            }
            else Stack.push(Integer.parseInt(S));
        }
        System.out.println(Stack.pop());
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) Deque<Integer> Stack = new ArrayDeque<>(); Stack new ArrayDeque<>() String S = sc.nextLine(); S sc.nextLine() sc.nextLine sc String list [] = S.split(" "); list S.split(" ") S.split S " " for(int i=0;i<list.length;i++){
            S = list[i];
            if(S.equals("+")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n1+n2);
            }
            else if(S.equals("-")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n2-n1);
            }
            else if(S.equals("*")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n1*n2);
            }
            else Stack.push(Integer.parseInt(S));
        } int i=0; int i=0; i 0 i<list.length i list.length list list.length i++ i++ i {
            S = list[i];
            if(S.equals("+")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n1+n2);
            }
            else if(S.equals("-")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n2-n1);
            }
            else if(S.equals("*")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n1*n2);
            }
            else Stack.push(Integer.parseInt(S));
        } {
            S = list[i];
            if(S.equals("+")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n1+n2);
            }
            else if(S.equals("-")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n2-n1);
            }
            else if(S.equals("*")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n1*n2);
            }
            else Stack.push(Integer.parseInt(S));
        } S = list[i] S list[i] list i if(S.equals("+")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n1+n2);
            }
            else if(S.equals("-")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n2-n1);
            }
            else if(S.equals("*")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n1*n2);
            }
            else Stack.push(Integer.parseInt(S)); S.equals("+") S.equals S "+" {
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n1+n2);
            } int n1 = Stack.pop(); n1 Stack.pop() Stack.pop Stack int n2 = Stack.pop(); n2 Stack.pop() Stack.pop Stack Stack.push(n1+n2) Stack.push Stack n1+n2 n1 n2 if(S.equals("-")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n2-n1);
            }
            else if(S.equals("*")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n1*n2);
            }
            else Stack.push(Integer.parseInt(S)); S.equals("-") S.equals S "-" {
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n2-n1);
            } int n1 = Stack.pop(); n1 Stack.pop() Stack.pop Stack int n2 = Stack.pop(); n2 Stack.pop() Stack.pop Stack Stack.push(n2-n1) Stack.push Stack n2-n1 n2 n1 if(S.equals("*")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n1*n2);
            }
            else Stack.push(Integer.parseInt(S)); S.equals("*") S.equals S "*" {
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n1*n2);
            } int n1 = Stack.pop(); n1 Stack.pop() Stack.pop Stack int n2 = Stack.pop(); n2 Stack.pop() Stack.pop Stack Stack.push(n1*n2) Stack.push Stack n1*n2 n1 n2 Stack.push(Integer.parseInt(S)) Stack.push Stack Integer.parseInt(S) Integer.parseInt Integer S 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 sc = new Scanner(System.in);
        Deque<Integer> Stack = new ArrayDeque<>();
        String S = sc.nextLine();
        String list [] = S.split(" ");
        for(int i=0;i<list.length;i++){
            S = list[i];
            if(S.equals("+")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n1+n2);
            }
            else if(S.equals("-")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n2-n1);
            }
            else if(S.equals("*")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n1*n2);
            }
            else Stack.push(Integer.parseInt(S));
        }
        System.out.println(Stack.pop());
    }
} public class Main {
    public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        Deque<Integer> Stack = new ArrayDeque<>();
        String S = sc.nextLine();
        String list [] = S.split(" ");
        for(int i=0;i<list.length;i++){
            S = list[i];
            if(S.equals("+")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n1+n2);
            }
            else if(S.equals("-")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n2-n1);
            }
            else if(S.equals("*")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n1*n2);
            }
            else Stack.push(Integer.parseInt(S));
        }
        System.out.println(Stack.pop());
    }
} Main
import java.util.*;
public class Main {
    public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        Deque<Integer> Stack = new ArrayDeque<>();
        String S = sc.nextLine();
        String list [] = S.split(" ");
        for(int i=0;i<list.length;i++){
            S = list[i];
            if(S.equals("+")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n1+n2);
            }
            else if(S.equals("-")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n2-n1);
            }
            else if(S.equals("*")){
                int n1 = Stack.pop();
                int n2 = Stack.pop();
                Stack.push(n1*n2);
            }
            else Stack.push(Integer.parseInt(S));
        }
        System.out.println(Stack.pop());
    }
}
