// ALDS 1_3_A Stack
import java.io.*;


class Main {

   static int[] S = new int[1000];
   static int top = 0;

   public static void main(String[] args) {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      try {
         int x;
         int a, b;
         String[] in = br.readLine().split(" ");
         for (int i = 0; i < in.length; i++) {
            if (in[i].equals("+")) {
               a = pop();
               b = pop();
               push(a + b);
            } else if (in[i].equals("-")) {
               b = pop();
               a = pop();
               push(a - b);
            } else if (in[i].equals("*")) {
               a = pop();
               b = pop();
               push(a * b);
            } else {
               x = Integer.parseInt(in[i]);
               push(x);
            }
         }
         System.out.println(pop());
      }
      catch (Exception e) {
         e.printStackTrace();
      }
   }
   static void push(int x) {
      top++;
      S[top] = x;
   }
   static int pop() {
      top--;
      return S[top + 1];
   }
} import java.io.*; io.* java class Main {

   static int[] S = new int[1000];
   static int top = 0;

   public static void main(String[] args) {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      try {
         int x;
         int a, b;
         String[] in = br.readLine().split(" ");
         for (int i = 0; i < in.length; i++) {
            if (in[i].equals("+")) {
               a = pop();
               b = pop();
               push(a + b);
            } else if (in[i].equals("-")) {
               b = pop();
               a = pop();
               push(a - b);
            } else if (in[i].equals("*")) {
               a = pop();
               b = pop();
               push(a * b);
            } else {
               x = Integer.parseInt(in[i]);
               push(x);
            }
         }
         System.out.println(pop());
      }
      catch (Exception e) {
         e.printStackTrace();
      }
   }
   static void push(int x) {
      top++;
      S[top] = x;
   }
   static int pop() {
      top--;
      return S[top + 1];
   }
} Main static int[] S = new int[1000]; S new int[1000] 1000 static int top = 0; top 0 public static void main(String[] args) {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      try {
         int x;
         int a, b;
         String[] in = br.readLine().split(" ");
         for (int i = 0; i < in.length; i++) {
            if (in[i].equals("+")) {
               a = pop();
               b = pop();
               push(a + b);
            } else if (in[i].equals("-")) {
               b = pop();
               a = pop();
               push(a - b);
            } else if (in[i].equals("*")) {
               a = pop();
               b = pop();
               push(a * b);
            } else {
               x = Integer.parseInt(in[i]);
               push(x);
            }
         }
         System.out.println(pop());
      }
      catch (Exception e) {
         e.printStackTrace();
      }
   } main {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      try {
         int x;
         int a, b;
         String[] in = br.readLine().split(" ");
         for (int i = 0; i < in.length; i++) {
            if (in[i].equals("+")) {
               a = pop();
               b = pop();
               push(a + b);
            } else if (in[i].equals("-")) {
               b = pop();
               a = pop();
               push(a - b);
            } else if (in[i].equals("*")) {
               a = pop();
               b = pop();
               push(a * b);
            } else {
               x = Integer.parseInt(in[i]);
               push(x);
            }
         }
         System.out.println(pop());
      }
      catch (Exception e) {
         e.printStackTrace();
      }
   } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) try {
         int x;
         int a, b;
         String[] in = br.readLine().split(" ");
         for (int i = 0; i < in.length; i++) {
            if (in[i].equals("+")) {
               a = pop();
               b = pop();
               push(a + b);
            } else if (in[i].equals("-")) {
               b = pop();
               a = pop();
               push(a - b);
            } else if (in[i].equals("*")) {
               a = pop();
               b = pop();
               push(a * b);
            } else {
               x = Integer.parseInt(in[i]);
               push(x);
            }
         }
         System.out.println(pop());
      }
      catch (Exception e) {
         e.printStackTrace();
      } catch (Exception e) {
         e.printStackTrace();
      } Exception e {
         e.printStackTrace();
      } e.printStackTrace() e.printStackTrace e {
         int x;
         int a, b;
         String[] in = br.readLine().split(" ");
         for (int i = 0; i < in.length; i++) {
            if (in[i].equals("+")) {
               a = pop();
               b = pop();
               push(a + b);
            } else if (in[i].equals("-")) {
               b = pop();
               a = pop();
               push(a - b);
            } else if (in[i].equals("*")) {
               a = pop();
               b = pop();
               push(a * b);
            } else {
               x = Integer.parseInt(in[i]);
               push(x);
            }
         }
         System.out.println(pop());
      } int x; x int a a b; b String[] in = br.readLine().split(" "); in br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " for (int i = 0; i < in.length; i++) {
            if (in[i].equals("+")) {
               a = pop();
               b = pop();
               push(a + b);
            } else if (in[i].equals("-")) {
               b = pop();
               a = pop();
               push(a - b);
            } else if (in[i].equals("*")) {
               a = pop();
               b = pop();
               push(a * b);
            } else {
               x = Integer.parseInt(in[i]);
               push(x);
            }
         } int i = 0; int i = 0; i 0 i < in.length i in.length in in.length i++ i++ i {
            if (in[i].equals("+")) {
               a = pop();
               b = pop();
               push(a + b);
            } else if (in[i].equals("-")) {
               b = pop();
               a = pop();
               push(a - b);
            } else if (in[i].equals("*")) {
               a = pop();
               b = pop();
               push(a * b);
            } else {
               x = Integer.parseInt(in[i]);
               push(x);
            }
         } {
            if (in[i].equals("+")) {
               a = pop();
               b = pop();
               push(a + b);
            } else if (in[i].equals("-")) {
               b = pop();
               a = pop();
               push(a - b);
            } else if (in[i].equals("*")) {
               a = pop();
               b = pop();
               push(a * b);
            } else {
               x = Integer.parseInt(in[i]);
               push(x);
            }
         } if (in[i].equals("+")) {
               a = pop();
               b = pop();
               push(a + b);
            } else if (in[i].equals("-")) {
               b = pop();
               a = pop();
               push(a - b);
            } else if (in[i].equals("*")) {
               a = pop();
               b = pop();
               push(a * b);
            } else {
               x = Integer.parseInt(in[i]);
               push(x);
            } in[i].equals("+") in[i].equals in[i] in i "+" {
               a = pop();
               b = pop();
               push(a + b);
            } a = pop() a pop() pop b = pop() b pop() pop push(a + b) push a + b a b if (in[i].equals("-")) {
               b = pop();
               a = pop();
               push(a - b);
            } else if (in[i].equals("*")) {
               a = pop();
               b = pop();
               push(a * b);
            } else {
               x = Integer.parseInt(in[i]);
               push(x);
            } in[i].equals("-") in[i].equals in[i] in i "-" {
               b = pop();
               a = pop();
               push(a - b);
            } b = pop() b pop() pop a = pop() a pop() pop push(a - b) push a - b a b if (in[i].equals("*")) {
               a = pop();
               b = pop();
               push(a * b);
            } else {
               x = Integer.parseInt(in[i]);
               push(x);
            } in[i].equals("*") in[i].equals in[i] in i "*" {
               a = pop();
               b = pop();
               push(a * b);
            } a = pop() a pop() pop b = pop() b pop() pop push(a * b) push a * b a b {
               x = Integer.parseInt(in[i]);
               push(x);
            } x = Integer.parseInt(in[i]) x Integer.parseInt(in[i]) Integer.parseInt Integer in[i] in i push(x) push x System.out.println(pop()) System.out.println System.out System System.out pop() pop String[] args args static void push(int x) {
      top++;
      S[top] = x;
   } push {
      top++;
      S[top] = x;
   } top++ top S[top] = x S[top] S top x int x x static int pop() {
      top--;
      return S[top + 1];
   } pop {
      top--;
      return S[top + 1];
   } top-- top return S[top + 1]; S[top + 1] S top + 1 top 1
// ALDS 1_3_A Stack
import java.io.*;


class Main {

   static int[] S = new int[1000];
   static int top = 0;

   public static void main(String[] args) {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      try {
         int x;
         int a, b;
         String[] in = br.readLine().split(" ");
         for (int i = 0; i < in.length; i++) {
            if (in[i].equals("+")) {
               a = pop();
               b = pop();
               push(a + b);
            } else if (in[i].equals("-")) {
               b = pop();
               a = pop();
               push(a - b);
            } else if (in[i].equals("*")) {
               a = pop();
               b = pop();
               push(a * b);
            } else {
               x = Integer.parseInt(in[i]);
               push(x);
            }
         }
         System.out.println(pop());
      }
      catch (Exception e) {
         e.printStackTrace();
      }
   }
   static void push(int x) {
      top++;
      S[top] = x;
   }
   static int pop() {
      top--;
      return S[top + 1];
   }
}