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


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



