import java.util.*;

class Main {
        public static void main(String args[]) {
                int[] stack = new int[1000];
                int i = 0;
                try (Scanner sc = new Scanner(System.in)) {
                        while (sc.hasNext()) {
                                String S = sc.next();
                                if (S.charAt(0) == '+') {
                                        stack[i-2] += stack[i-1];
                                        i--;
                                } else if(S.charAt(0) == '*'){
                                        stack[i-2] *= stack[i-1];
                                        i--;
                                } else if(S.charAt(0) == '-'){
                                        stack[i-2] -= stack[i-1];
                                        i--;
                                } else {
                                        stack[i] = Integer.parseInt(S);
                                        i++;
                                }
                        }
                }
                System.out.println(stack[0]);
        }
} import java.util.*; util.* java class Main {
        public static void main(String args[]) {
                int[] stack = new int[1000];
                int i = 0;
                try (Scanner sc = new Scanner(System.in)) {
                        while (sc.hasNext()) {
                                String S = sc.next();
                                if (S.charAt(0) == '+') {
                                        stack[i-2] += stack[i-1];
                                        i--;
                                } else if(S.charAt(0) == '*'){
                                        stack[i-2] *= stack[i-1];
                                        i--;
                                } else if(S.charAt(0) == '-'){
                                        stack[i-2] -= stack[i-1];
                                        i--;
                                } else {
                                        stack[i] = Integer.parseInt(S);
                                        i++;
                                }
                        }
                }
                System.out.println(stack[0]);
        }
} Main public static void main(String args[]) {
                int[] stack = new int[1000];
                int i = 0;
                try (Scanner sc = new Scanner(System.in)) {
                        while (sc.hasNext()) {
                                String S = sc.next();
                                if (S.charAt(0) == '+') {
                                        stack[i-2] += stack[i-1];
                                        i--;
                                } else if(S.charAt(0) == '*'){
                                        stack[i-2] *= stack[i-1];
                                        i--;
                                } else if(S.charAt(0) == '-'){
                                        stack[i-2] -= stack[i-1];
                                        i--;
                                } else {
                                        stack[i] = Integer.parseInt(S);
                                        i++;
                                }
                        }
                }
                System.out.println(stack[0]);
        } main {
                int[] stack = new int[1000];
                int i = 0;
                try (Scanner sc = new Scanner(System.in)) {
                        while (sc.hasNext()) {
                                String S = sc.next();
                                if (S.charAt(0) == '+') {
                                        stack[i-2] += stack[i-1];
                                        i--;
                                } else if(S.charAt(0) == '*'){
                                        stack[i-2] *= stack[i-1];
                                        i--;
                                } else if(S.charAt(0) == '-'){
                                        stack[i-2] -= stack[i-1];
                                        i--;
                                } else {
                                        stack[i] = Integer.parseInt(S);
                                        i++;
                                }
                        }
                }
                System.out.println(stack[0]);
        } int[] stack = new int[1000]; stack new int[1000] 1000 int i = 0; i 0 try (Scanner sc = new Scanner(System.in)) {
                        while (sc.hasNext()) {
                                String S = sc.next();
                                if (S.charAt(0) == '+') {
                                        stack[i-2] += stack[i-1];
                                        i--;
                                } else if(S.charAt(0) == '*'){
                                        stack[i-2] *= stack[i-1];
                                        i--;
                                } else if(S.charAt(0) == '-'){
                                        stack[i-2] -= stack[i-1];
                                        i--;
                                } else {
                                        stack[i] = Integer.parseInt(S);
                                        i++;
                                }
                        }
                } {
                        while (sc.hasNext()) {
                                String S = sc.next();
                                if (S.charAt(0) == '+') {
                                        stack[i-2] += stack[i-1];
                                        i--;
                                } else if(S.charAt(0) == '*'){
                                        stack[i-2] *= stack[i-1];
                                        i--;
                                } else if(S.charAt(0) == '-'){
                                        stack[i-2] -= stack[i-1];
                                        i--;
                                } else {
                                        stack[i] = Integer.parseInt(S);
                                        i++;
                                }
                        }
                } Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) while (sc.hasNext()) {
                                String S = sc.next();
                                if (S.charAt(0) == '+') {
                                        stack[i-2] += stack[i-1];
                                        i--;
                                } else if(S.charAt(0) == '*'){
                                        stack[i-2] *= stack[i-1];
                                        i--;
                                } else if(S.charAt(0) == '-'){
                                        stack[i-2] -= stack[i-1];
                                        i--;
                                } else {
                                        stack[i] = Integer.parseInt(S);
                                        i++;
                                }
                        } sc.hasNext() sc.hasNext sc {
                                String S = sc.next();
                                if (S.charAt(0) == '+') {
                                        stack[i-2] += stack[i-1];
                                        i--;
                                } else if(S.charAt(0) == '*'){
                                        stack[i-2] *= stack[i-1];
                                        i--;
                                } else if(S.charAt(0) == '-'){
                                        stack[i-2] -= stack[i-1];
                                        i--;
                                } else {
                                        stack[i] = Integer.parseInt(S);
                                        i++;
                                }
                        } String S = sc.next(); S sc.next() sc.next sc if (S.charAt(0) == '+') {
                                        stack[i-2] += stack[i-1];
                                        i--;
                                } else if(S.charAt(0) == '*'){
                                        stack[i-2] *= stack[i-1];
                                        i--;
                                } else if(S.charAt(0) == '-'){
                                        stack[i-2] -= stack[i-1];
                                        i--;
                                } else {
                                        stack[i] = Integer.parseInt(S);
                                        i++;
                                } S.charAt(0) == '+' S.charAt(0) S.charAt S 0 '+' {
                                        stack[i-2] += stack[i-1];
                                        i--;
                                } stack[i-2] += stack[i-1] stack[i-2] stack i-2 i 2 stack[i-1] stack i-1 i 1 i-- i if(S.charAt(0) == '*'){
                                        stack[i-2] *= stack[i-1];
                                        i--;
                                } else if(S.charAt(0) == '-'){
                                        stack[i-2] -= stack[i-1];
                                        i--;
                                } else {
                                        stack[i] = Integer.parseInt(S);
                                        i++;
                                } S.charAt(0) == '*' S.charAt(0) S.charAt S 0 '*' {
                                        stack[i-2] *= stack[i-1];
                                        i--;
                                } stack[i-2] *= stack[i-1] stack[i-2] stack i-2 i 2 stack[i-1] stack i-1 i 1 i-- i if(S.charAt(0) == '-'){
                                        stack[i-2] -= stack[i-1];
                                        i--;
                                } else {
                                        stack[i] = Integer.parseInt(S);
                                        i++;
                                } S.charAt(0) == '-' S.charAt(0) S.charAt S 0 '-' {
                                        stack[i-2] -= stack[i-1];
                                        i--;
                                } stack[i-2] -= stack[i-1] stack[i-2] stack i-2 i 2 stack[i-1] stack i-1 i 1 i-- i {
                                        stack[i] = Integer.parseInt(S);
                                        i++;
                                } stack[i] = Integer.parseInt(S) stack[i] stack i Integer.parseInt(S) Integer.parseInt Integer S i++ i System.out.println(stack[0]) System.out.println System.out System System.out stack[0] stack 0 String args[] args
import java.util.*;

class Main {
        public static void main(String args[]) {
                int[] stack = new int[1000];
                int i = 0;
                try (Scanner sc = new Scanner(System.in)) {
                        while (sc.hasNext()) {
                                String S = sc.next();
                                if (S.charAt(0) == '+') {
                                        stack[i-2] += stack[i-1];
                                        i--;
                                } else if(S.charAt(0) == '*'){
                                        stack[i-2] *= stack[i-1];
                                        i--;
                                } else if(S.charAt(0) == '-'){
                                        stack[i-2] -= stack[i-1];
                                        i--;
                                } else {
                                        stack[i] = Integer.parseInt(S);
                                        i++;
                                }
                        }
                }
                System.out.println(stack[0]);
        }
}