import java.util.Scanner;
import java.util.Stack;

public class Main{
    //problem from izu
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String next = in.nextLine();
        String[] str = next.split(" ");
        //System.out.println(str[1]);
        Stack<Integer> stack = new Stack<>();
        int length = str.length;
        for(int i = 0; i<length; i++){
            if(str[i].charAt(0)=='+' || str[i].charAt(0)=='-' || str[i].charAt(0)=='*'){
                int a = stack.pop();
                int b = stack.pop();
                if(str[i].charAt(0)=='+'){
                    stack.push(a+b);
                } else if(str[i].charAt(0)=='-'){
                    stack.push(b-a);
                } else if(str[i].charAt(0)=='*'){
                    stack.push(a*b);
                }
            }
            else {
                int temp = 0;
                for(int k = 0; k<str[i].length(); k++){
                    temp*=10;
                    temp+=(str[i].charAt(k) - '0');
                }
                stack.push(temp);
                //System.out.println(temp);
            }
        }
        System.out.println(stack.pop());
        
    }

}
 import java.util.Scanner; Scanner java.util import java.util.Stack; Stack java.util public class Main{
    //problem from izu
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String next = in.nextLine();
        String[] str = next.split(" ");
        //System.out.println(str[1]);
        Stack<Integer> stack = new Stack<>();
        int length = str.length;
        for(int i = 0; i<length; i++){
            if(str[i].charAt(0)=='+' || str[i].charAt(0)=='-' || str[i].charAt(0)=='*'){
                int a = stack.pop();
                int b = stack.pop();
                if(str[i].charAt(0)=='+'){
                    stack.push(a+b);
                } else if(str[i].charAt(0)=='-'){
                    stack.push(b-a);
                } else if(str[i].charAt(0)=='*'){
                    stack.push(a*b);
                }
            }
            else {
                int temp = 0;
                for(int k = 0; k<str[i].length(); k++){
                    temp*=10;
                    temp+=(str[i].charAt(k) - '0');
                }
                stack.push(temp);
                //System.out.println(temp);
            }
        }
        System.out.println(stack.pop());
        
    }

} Main //problem from izu
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String next = in.nextLine();
        String[] str = next.split(" ");
        //System.out.println(str[1]);
        Stack<Integer> stack = new Stack<>();
        int length = str.length;
        for(int i = 0; i<length; i++){
            if(str[i].charAt(0)=='+' || str[i].charAt(0)=='-' || str[i].charAt(0)=='*'){
                int a = stack.pop();
                int b = stack.pop();
                if(str[i].charAt(0)=='+'){
                    stack.push(a+b);
                } else if(str[i].charAt(0)=='-'){
                    stack.push(b-a);
                } else if(str[i].charAt(0)=='*'){
                    stack.push(a*b);
                }
            }
            else {
                int temp = 0;
                for(int k = 0; k<str[i].length(); k++){
                    temp*=10;
                    temp+=(str[i].charAt(k) - '0');
                }
                stack.push(temp);
                //System.out.println(temp);
            }
        }
        System.out.println(stack.pop());
        
    } main {
        Scanner in = new Scanner(System.in);
        String next = in.nextLine();
        String[] str = next.split(" ");
        //System.out.println(str[1]);
        Stack<Integer> stack = new Stack<>();
        int length = str.length;
        for(int i = 0; i<length; i++){
            if(str[i].charAt(0)=='+' || str[i].charAt(0)=='-' || str[i].charAt(0)=='*'){
                int a = stack.pop();
                int b = stack.pop();
                if(str[i].charAt(0)=='+'){
                    stack.push(a+b);
                } else if(str[i].charAt(0)=='-'){
                    stack.push(b-a);
                } else if(str[i].charAt(0)=='*'){
                    stack.push(a*b);
                }
            }
            else {
                int temp = 0;
                for(int k = 0; k<str[i].length(); k++){
                    temp*=10;
                    temp+=(str[i].charAt(k) - '0');
                }
                stack.push(temp);
                //System.out.println(temp);
            }
        }
        System.out.println(stack.pop());
        
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) String next = in.nextLine(); next in.nextLine() in.nextLine in String[] str = next.split(" "); str next.split(" ") next.split next " " Stack<Integer> stack = new Stack<>(); stack new Stack<>() int length = str.length; length str.length str str.length for(int i = 0; i<length; i++){
            if(str[i].charAt(0)=='+' || str[i].charAt(0)=='-' || str[i].charAt(0)=='*'){
                int a = stack.pop();
                int b = stack.pop();
                if(str[i].charAt(0)=='+'){
                    stack.push(a+b);
                } else if(str[i].charAt(0)=='-'){
                    stack.push(b-a);
                } else if(str[i].charAt(0)=='*'){
                    stack.push(a*b);
                }
            }
            else {
                int temp = 0;
                for(int k = 0; k<str[i].length(); k++){
                    temp*=10;
                    temp+=(str[i].charAt(k) - '0');
                }
                stack.push(temp);
                //System.out.println(temp);
            }
        } int i = 0; int i = 0; i 0 i<length i length i++ i++ i {
            if(str[i].charAt(0)=='+' || str[i].charAt(0)=='-' || str[i].charAt(0)=='*'){
                int a = stack.pop();
                int b = stack.pop();
                if(str[i].charAt(0)=='+'){
                    stack.push(a+b);
                } else if(str[i].charAt(0)=='-'){
                    stack.push(b-a);
                } else if(str[i].charAt(0)=='*'){
                    stack.push(a*b);
                }
            }
            else {
                int temp = 0;
                for(int k = 0; k<str[i].length(); k++){
                    temp*=10;
                    temp+=(str[i].charAt(k) - '0');
                }
                stack.push(temp);
                //System.out.println(temp);
            }
        } {
            if(str[i].charAt(0)=='+' || str[i].charAt(0)=='-' || str[i].charAt(0)=='*'){
                int a = stack.pop();
                int b = stack.pop();
                if(str[i].charAt(0)=='+'){
                    stack.push(a+b);
                } else if(str[i].charAt(0)=='-'){
                    stack.push(b-a);
                } else if(str[i].charAt(0)=='*'){
                    stack.push(a*b);
                }
            }
            else {
                int temp = 0;
                for(int k = 0; k<str[i].length(); k++){
                    temp*=10;
                    temp+=(str[i].charAt(k) - '0');
                }
                stack.push(temp);
                //System.out.println(temp);
            }
        } if(str[i].charAt(0)=='+' || str[i].charAt(0)=='-' || str[i].charAt(0)=='*'){
                int a = stack.pop();
                int b = stack.pop();
                if(str[i].charAt(0)=='+'){
                    stack.push(a+b);
                } else if(str[i].charAt(0)=='-'){
                    stack.push(b-a);
                } else if(str[i].charAt(0)=='*'){
                    stack.push(a*b);
                }
            }
            else {
                int temp = 0;
                for(int k = 0; k<str[i].length(); k++){
                    temp*=10;
                    temp+=(str[i].charAt(k) - '0');
                }
                stack.push(temp);
                //System.out.println(temp);
            } str[i].charAt(0)=='+' || str[i].charAt(0)=='-' || str[i].charAt(0)=='*' str[i].charAt(0)=='+' || str[i].charAt(0)=='-' || str[i].charAt(0)=='*' str[i].charAt(0)=='+' str[i].charAt(0) str[i].charAt str[i] str i 0 '+' str[i].charAt(0)=='-' str[i].charAt(0) str[i].charAt str[i] str i 0 '-' str[i].charAt(0)=='*' str[i].charAt(0) str[i].charAt str[i] str i 0 '*' {
                int a = stack.pop();
                int b = stack.pop();
                if(str[i].charAt(0)=='+'){
                    stack.push(a+b);
                } else if(str[i].charAt(0)=='-'){
                    stack.push(b-a);
                } else if(str[i].charAt(0)=='*'){
                    stack.push(a*b);
                }
            } int a = stack.pop(); a stack.pop() stack.pop stack int b = stack.pop(); b stack.pop() stack.pop stack if(str[i].charAt(0)=='+'){
                    stack.push(a+b);
                } else if(str[i].charAt(0)=='-'){
                    stack.push(b-a);
                } else if(str[i].charAt(0)=='*'){
                    stack.push(a*b);
                } str[i].charAt(0)=='+' str[i].charAt(0) str[i].charAt str[i] str i 0 '+' {
                    stack.push(a+b);
                } stack.push(a+b) stack.push stack a+b a b if(str[i].charAt(0)=='-'){
                    stack.push(b-a);
                } else if(str[i].charAt(0)=='*'){
                    stack.push(a*b);
                } str[i].charAt(0)=='-' str[i].charAt(0) str[i].charAt str[i] str i 0 '-' {
                    stack.push(b-a);
                } stack.push(b-a) stack.push stack b-a b a if(str[i].charAt(0)=='*'){
                    stack.push(a*b);
                } str[i].charAt(0)=='*' str[i].charAt(0) str[i].charAt str[i] str i 0 '*' {
                    stack.push(a*b);
                } stack.push(a*b) stack.push stack a*b a b {
                int temp = 0;
                for(int k = 0; k<str[i].length(); k++){
                    temp*=10;
                    temp+=(str[i].charAt(k) - '0');
                }
                stack.push(temp);
                //System.out.println(temp);
            } int temp = 0; temp 0 for(int k = 0; k<str[i].length(); k++){
                    temp*=10;
                    temp+=(str[i].charAt(k) - '0');
                } int k = 0; int k = 0; k 0 k<str[i].length() k str[i].length() str[i].length str[i] str i k++ k++ k {
                    temp*=10;
                    temp+=(str[i].charAt(k) - '0');
                } {
                    temp*=10;
                    temp+=(str[i].charAt(k) - '0');
                } temp*=10 temp 10 temp+=(str[i].charAt(k) - '0') temp (str[i].charAt(k) - '0') str[i].charAt(k) str[i].charAt str[i] str i k '0' stack.push(temp) stack.push stack temp System.out.println(stack.pop()) System.out.println System.out System System.out stack.pop() stack.pop stack String[] args args public class Main{
    //problem from izu
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String next = in.nextLine();
        String[] str = next.split(" ");
        //System.out.println(str[1]);
        Stack<Integer> stack = new Stack<>();
        int length = str.length;
        for(int i = 0; i<length; i++){
            if(str[i].charAt(0)=='+' || str[i].charAt(0)=='-' || str[i].charAt(0)=='*'){
                int a = stack.pop();
                int b = stack.pop();
                if(str[i].charAt(0)=='+'){
                    stack.push(a+b);
                } else if(str[i].charAt(0)=='-'){
                    stack.push(b-a);
                } else if(str[i].charAt(0)=='*'){
                    stack.push(a*b);
                }
            }
            else {
                int temp = 0;
                for(int k = 0; k<str[i].length(); k++){
                    temp*=10;
                    temp+=(str[i].charAt(k) - '0');
                }
                stack.push(temp);
                //System.out.println(temp);
            }
        }
        System.out.println(stack.pop());
        
    }

} public class Main{
    //problem from izu
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String next = in.nextLine();
        String[] str = next.split(" ");
        //System.out.println(str[1]);
        Stack<Integer> stack = new Stack<>();
        int length = str.length;
        for(int i = 0; i<length; i++){
            if(str[i].charAt(0)=='+' || str[i].charAt(0)=='-' || str[i].charAt(0)=='*'){
                int a = stack.pop();
                int b = stack.pop();
                if(str[i].charAt(0)=='+'){
                    stack.push(a+b);
                } else if(str[i].charAt(0)=='-'){
                    stack.push(b-a);
                } else if(str[i].charAt(0)=='*'){
                    stack.push(a*b);
                }
            }
            else {
                int temp = 0;
                for(int k = 0; k<str[i].length(); k++){
                    temp*=10;
                    temp+=(str[i].charAt(k) - '0');
                }
                stack.push(temp);
                //System.out.println(temp);
            }
        }
        System.out.println(stack.pop());
        
    }

} Main
import java.util.Scanner;
import java.util.Stack;

public class Main{
    //problem from izu
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String next = in.nextLine();
        String[] str = next.split(" ");
        //System.out.println(str[1]);
        Stack<Integer> stack = new Stack<>();
        int length = str.length;
        for(int i = 0; i<length; i++){
            if(str[i].charAt(0)=='+' || str[i].charAt(0)=='-' || str[i].charAt(0)=='*'){
                int a = stack.pop();
                int b = stack.pop();
                if(str[i].charAt(0)=='+'){
                    stack.push(a+b);
                } else if(str[i].charAt(0)=='-'){
                    stack.push(b-a);
                } else if(str[i].charAt(0)=='*'){
                    stack.push(a*b);
                }
            }
            else {
                int temp = 0;
                for(int k = 0; k<str[i].length(); k++){
                    temp*=10;
                    temp+=(str[i].charAt(k) - '0');
                }
                stack.push(temp);
                //System.out.println(temp);
            }
        }
        System.out.println(stack.pop());
        
    }

}

