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

class Main{
        static final String[] operator = {"+", "-", "*"};
        static Stack<Integer> stack = new Stack<Integer>();
        static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        static void doPlus(){
                int a=stack.pop();
                a += stack.pop();
                stack.push(a);
        }
        static void doMinus(){
                int a = 0 - stack.pop();
                a += stack.pop();
                stack.push(a);
        }
        static void doMul(){
                int a=stack.pop();
                a *= stack.pop();
                stack.push(a);
        }
        static void doPop(String i){
                stack.push(new Integer(i));
        }
        public static void main(String[] args) throws IOException{
                String[] elements = br.readLine().split(" ");
                for(String e : elements){
                        switch (e){
                                case "+":
                                        doPlus();
                                        break;
                                case "-":
                                        doMinus();
                                        break;
                                case "*":
                                        doMul();
                                        break;
                                default:
                                        doPop(e);
                        }
                }
                while(!stack.empty()){
                        System.out.print(stack.pop());
                        if(!stack.empty())
                                System.out.print(" ");
                }
                System.out.println();
        }
} import java.util.*; util.* java import java.io.*; io.* java class Main{
        static final String[] operator = {"+", "-", "*"};
        static Stack<Integer> stack = new Stack<Integer>();
        static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        static void doPlus(){
                int a=stack.pop();
                a += stack.pop();
                stack.push(a);
        }
        static void doMinus(){
                int a = 0 - stack.pop();
                a += stack.pop();
                stack.push(a);
        }
        static void doMul(){
                int a=stack.pop();
                a *= stack.pop();
                stack.push(a);
        }
        static void doPop(String i){
                stack.push(new Integer(i));
        }
        public static void main(String[] args) throws IOException{
                String[] elements = br.readLine().split(" ");
                for(String e : elements){
                        switch (e){
                                case "+":
                                        doPlus();
                                        break;
                                case "-":
                                        doMinus();
                                        break;
                                case "*":
                                        doMul();
                                        break;
                                default:
                                        doPop(e);
                        }
                }
                while(!stack.empty()){
                        System.out.print(stack.pop());
                        if(!stack.empty())
                                System.out.print(" ");
                }
                System.out.println();
        }
} Main static final String[] operator = {"+", "-", "*"}; operator {"+", "-", "*"} "+" "-" "*" static Stack<Integer> stack = new Stack<Integer>(); stack new Stack<Integer>() static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) static void doPlus(){
                int a=stack.pop();
                a += stack.pop();
                stack.push(a);
        } doPlus {
                int a=stack.pop();
                a += stack.pop();
                stack.push(a);
        } int a=stack.pop(); a stack.pop() stack.pop stack a += stack.pop() a stack.pop() stack.pop stack stack.push(a) stack.push stack a static void doMinus(){
                int a = 0 - stack.pop();
                a += stack.pop();
                stack.push(a);
        } doMinus {
                int a = 0 - stack.pop();
                a += stack.pop();
                stack.push(a);
        } int a = 0 - stack.pop(); a 0 - stack.pop() 0 stack.pop() stack.pop stack a += stack.pop() a stack.pop() stack.pop stack stack.push(a) stack.push stack a static void doMul(){
                int a=stack.pop();
                a *= stack.pop();
                stack.push(a);
        } doMul {
                int a=stack.pop();
                a *= stack.pop();
                stack.push(a);
        } int a=stack.pop(); a stack.pop() stack.pop stack a *= stack.pop() a stack.pop() stack.pop stack stack.push(a) stack.push stack a static void doPop(String i){
                stack.push(new Integer(i));
        } doPop {
                stack.push(new Integer(i));
        } stack.push(new Integer(i)) stack.push stack new Integer(i) String i i public static void main(String[] args) throws IOException{
                String[] elements = br.readLine().split(" ");
                for(String e : elements){
                        switch (e){
                                case "+":
                                        doPlus();
                                        break;
                                case "-":
                                        doMinus();
                                        break;
                                case "*":
                                        doMul();
                                        break;
                                default:
                                        doPop(e);
                        }
                }
                while(!stack.empty()){
                        System.out.print(stack.pop());
                        if(!stack.empty())
                                System.out.print(" ");
                }
                System.out.println();
        } main {
                String[] elements = br.readLine().split(" ");
                for(String e : elements){
                        switch (e){
                                case "+":
                                        doPlus();
                                        break;
                                case "-":
                                        doMinus();
                                        break;
                                case "*":
                                        doMul();
                                        break;
                                default:
                                        doPop(e);
                        }
                }
                while(!stack.empty()){
                        System.out.print(stack.pop());
                        if(!stack.empty())
                                System.out.print(" ");
                }
                System.out.println();
        } String[] elements = br.readLine().split(" "); elements br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " for(String e : elements){
                        switch (e){
                                case "+":
                                        doPlus();
                                        break;
                                case "-":
                                        doMinus();
                                        break;
                                case "*":
                                        doMul();
                                        break;
                                default:
                                        doPop(e);
                        }
                } String e elements {
                        switch (e){
                                case "+":
                                        doPlus();
                                        break;
                                case "-":
                                        doMinus();
                                        break;
                                case "*":
                                        doMul();
                                        break;
                                default:
                                        doPop(e);
                        }
                } {
                        switch (e){
                                case "+":
                                        doPlus();
                                        break;
                                case "-":
                                        doMinus();
                                        break;
                                case "*":
                                        doMul();
                                        break;
                                default:
                                        doPop(e);
                        }
                } switch (e){
                                case "+":
                                        doPlus();
                                        break;
                                case "-":
                                        doMinus();
                                        break;
                                case "*":
                                        doMul();
                                        break;
                                default:
                                        doPop(e);
                        } e case "+": "+" case "+": doPlus() doPlus break; case "-": "-" case "-": doMinus() doMinus break; case "*": "*" case "*": doMul() doMul break; default: default: doPop(e) doPop e while(!stack.empty()){
                        System.out.print(stack.pop());
                        if(!stack.empty())
                                System.out.print(" ");
                } !stack.empty() stack.empty() stack.empty stack {
                        System.out.print(stack.pop());
                        if(!stack.empty())
                                System.out.print(" ");
                } System.out.print(stack.pop()) System.out.print System.out System System.out stack.pop() stack.pop stack if(!stack.empty())
                                System.out.print(" "); !stack.empty() stack.empty() stack.empty stack System.out.print(" ") System.out.print System.out System System.out " " System.out.println() System.out.println System.out System System.out String[] args args
import java.util.*;
import java.io.*;

class Main{
        static final String[] operator = {"+", "-", "*"};
        static Stack<Integer> stack = new Stack<Integer>();
        static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        static void doPlus(){
                int a=stack.pop();
                a += stack.pop();
                stack.push(a);
        }
        static void doMinus(){
                int a = 0 - stack.pop();
                a += stack.pop();
                stack.push(a);
        }
        static void doMul(){
                int a=stack.pop();
                a *= stack.pop();
                stack.push(a);
        }
        static void doPop(String i){
                stack.push(new Integer(i));
        }
        public static void main(String[] args) throws IOException{
                String[] elements = br.readLine().split(" ");
                for(String e : elements){
                        switch (e){
                                case "+":
                                        doPlus();
                                        break;
                                case "-":
                                        doMinus();
                                        break;
                                case "*":
                                        doMul();
                                        break;
                                default:
                                        doPop(e);
                        }
                }
                while(!stack.empty()){
                        System.out.print(stack.pop());
                        if(!stack.empty())
                                System.out.print(" ");
                }
                System.out.println();
        }
}