import java.util.Arrays;
import java.util.Scanner;

public class Main {
  static int Max = 1000;
  static int top;
  static int[] Stack = new int[Max];

  public static void main(final String[] args) {
    initialize();
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    String[] str = s.split(" ");
    for (int i = 0; i < str.length; i++) {
      if (Character.isDigit(str[i].charAt(0))) {
        push(Integer.parseInt(str[i]));
      }
      else if (String.valueOf(str[i]).equals("+")) {
        int a = pop();
        int b = pop();
        push(a + b);
      }
      else if (String.valueOf(str[i]).equals("-")) {
        int a = pop();
        int b = pop();
        push(b - a);
      }
      else if (String.valueOf(str[i]).equals("*")) {
        int a = pop();
        int b = pop();
        push(a * b);
      }
    }
    System.out.println(pop());
  }

  private static void initialize() {
    top = 0;
  }

  private static boolean isEmpty() {
    return top == 0;
  }

  private static boolean isFull() {
    return top >= Max - 1;
  }

  private static void push(int x) {
    if (isFull()) {
      throw new Error("Over Flow");
    }
    top++;
    Stack[top] = x;
  }

  private static int pop() {
    if (isEmpty()) {
      throw new Error("Under Flow");
    }
    top--;
    return Stack[top + 1];
  }

  private static void print(int[] A) {
    System.out.println(Arrays.toString(A));
  }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
  static int Max = 1000;
  static int top;
  static int[] Stack = new int[Max];

  public static void main(final String[] args) {
    initialize();
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    String[] str = s.split(" ");
    for (int i = 0; i < str.length; i++) {
      if (Character.isDigit(str[i].charAt(0))) {
        push(Integer.parseInt(str[i]));
      }
      else if (String.valueOf(str[i]).equals("+")) {
        int a = pop();
        int b = pop();
        push(a + b);
      }
      else if (String.valueOf(str[i]).equals("-")) {
        int a = pop();
        int b = pop();
        push(b - a);
      }
      else if (String.valueOf(str[i]).equals("*")) {
        int a = pop();
        int b = pop();
        push(a * b);
      }
    }
    System.out.println(pop());
  }

  private static void initialize() {
    top = 0;
  }

  private static boolean isEmpty() {
    return top == 0;
  }

  private static boolean isFull() {
    return top >= Max - 1;
  }

  private static void push(int x) {
    if (isFull()) {
      throw new Error("Over Flow");
    }
    top++;
    Stack[top] = x;
  }

  private static int pop() {
    if (isEmpty()) {
      throw new Error("Under Flow");
    }
    top--;
    return Stack[top + 1];
  }

  private static void print(int[] A) {
    System.out.println(Arrays.toString(A));
  }
} Main static int Max = 1000; Max 1000 static int top; top static int[] Stack = new int[Max]; Stack new int[Max] Max public static void main(final String[] args) {
    initialize();
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    String[] str = s.split(" ");
    for (int i = 0; i < str.length; i++) {
      if (Character.isDigit(str[i].charAt(0))) {
        push(Integer.parseInt(str[i]));
      }
      else if (String.valueOf(str[i]).equals("+")) {
        int a = pop();
        int b = pop();
        push(a + b);
      }
      else if (String.valueOf(str[i]).equals("-")) {
        int a = pop();
        int b = pop();
        push(b - a);
      }
      else if (String.valueOf(str[i]).equals("*")) {
        int a = pop();
        int b = pop();
        push(a * b);
      }
    }
    System.out.println(pop());
  } main {
    initialize();
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    String[] str = s.split(" ");
    for (int i = 0; i < str.length; i++) {
      if (Character.isDigit(str[i].charAt(0))) {
        push(Integer.parseInt(str[i]));
      }
      else if (String.valueOf(str[i]).equals("+")) {
        int a = pop();
        int b = pop();
        push(a + b);
      }
      else if (String.valueOf(str[i]).equals("-")) {
        int a = pop();
        int b = pop();
        push(b - a);
      }
      else if (String.valueOf(str[i]).equals("*")) {
        int a = pop();
        int b = pop();
        push(a * b);
      }
    }
    System.out.println(pop());
  } initialize() initialize Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.nextLine(); s sc.nextLine() sc.nextLine sc String[] str = s.split(" "); str s.split(" ") s.split s " " for (int i = 0; i < str.length; i++) {
      if (Character.isDigit(str[i].charAt(0))) {
        push(Integer.parseInt(str[i]));
      }
      else if (String.valueOf(str[i]).equals("+")) {
        int a = pop();
        int b = pop();
        push(a + b);
      }
      else if (String.valueOf(str[i]).equals("-")) {
        int a = pop();
        int b = pop();
        push(b - a);
      }
      else if (String.valueOf(str[i]).equals("*")) {
        int a = pop();
        int b = pop();
        push(a * b);
      }
    } int i = 0; int i = 0; i 0 i < str.length i str.length str str.length i++ i++ i {
      if (Character.isDigit(str[i].charAt(0))) {
        push(Integer.parseInt(str[i]));
      }
      else if (String.valueOf(str[i]).equals("+")) {
        int a = pop();
        int b = pop();
        push(a + b);
      }
      else if (String.valueOf(str[i]).equals("-")) {
        int a = pop();
        int b = pop();
        push(b - a);
      }
      else if (String.valueOf(str[i]).equals("*")) {
        int a = pop();
        int b = pop();
        push(a * b);
      }
    } {
      if (Character.isDigit(str[i].charAt(0))) {
        push(Integer.parseInt(str[i]));
      }
      else if (String.valueOf(str[i]).equals("+")) {
        int a = pop();
        int b = pop();
        push(a + b);
      }
      else if (String.valueOf(str[i]).equals("-")) {
        int a = pop();
        int b = pop();
        push(b - a);
      }
      else if (String.valueOf(str[i]).equals("*")) {
        int a = pop();
        int b = pop();
        push(a * b);
      }
    } if (Character.isDigit(str[i].charAt(0))) {
        push(Integer.parseInt(str[i]));
      }
      else if (String.valueOf(str[i]).equals("+")) {
        int a = pop();
        int b = pop();
        push(a + b);
      }
      else if (String.valueOf(str[i]).equals("-")) {
        int a = pop();
        int b = pop();
        push(b - a);
      }
      else if (String.valueOf(str[i]).equals("*")) {
        int a = pop();
        int b = pop();
        push(a * b);
      } Character.isDigit(str[i].charAt(0)) Character.isDigit Character str[i].charAt(0) str[i].charAt str[i] str i 0 {
        push(Integer.parseInt(str[i]));
      } push(Integer.parseInt(str[i])) push Integer.parseInt(str[i]) Integer.parseInt Integer str[i] str i if (String.valueOf(str[i]).equals("+")) {
        int a = pop();
        int b = pop();
        push(a + b);
      }
      else if (String.valueOf(str[i]).equals("-")) {
        int a = pop();
        int b = pop();
        push(b - a);
      }
      else if (String.valueOf(str[i]).equals("*")) {
        int a = pop();
        int b = pop();
        push(a * b);
      } String.valueOf(str[i]).equals("+") String.valueOf(str[i]).equals String.valueOf(str[i]) String.valueOf String str[i] str i "+" {
        int a = pop();
        int b = pop();
        push(a + b);
      } int a = pop(); a pop() pop int b = pop(); b pop() pop push(a + b) push a + b a b if (String.valueOf(str[i]).equals("-")) {
        int a = pop();
        int b = pop();
        push(b - a);
      }
      else if (String.valueOf(str[i]).equals("*")) {
        int a = pop();
        int b = pop();
        push(a * b);
      } String.valueOf(str[i]).equals("-") String.valueOf(str[i]).equals String.valueOf(str[i]) String.valueOf String str[i] str i "-" {
        int a = pop();
        int b = pop();
        push(b - a);
      } int a = pop(); a pop() pop int b = pop(); b pop() pop push(b - a) push b - a b a if (String.valueOf(str[i]).equals("*")) {
        int a = pop();
        int b = pop();
        push(a * b);
      } String.valueOf(str[i]).equals("*") String.valueOf(str[i]).equals String.valueOf(str[i]) String.valueOf String str[i] str i "*" {
        int a = pop();
        int b = pop();
        push(a * b);
      } int a = pop(); a pop() pop int b = pop(); b pop() pop push(a * b) push a * b a b System.out.println(pop()) System.out.println System.out System System.out pop() pop final String[] args args private static void initialize() {
    top = 0;
  } initialize {
    top = 0;
  } top = 0 top 0 private static boolean isEmpty() {
    return top == 0;
  } isEmpty {
    return top == 0;
  } return top == 0; top == 0 top 0 private static boolean isFull() {
    return top >= Max - 1;
  } isFull {
    return top >= Max - 1;
  } return top >= Max - 1; top >= Max - 1 top Max - 1 Max 1 private static void push(int x) {
    if (isFull()) {
      throw new Error("Over Flow");
    }
    top++;
    Stack[top] = x;
  } push {
    if (isFull()) {
      throw new Error("Over Flow");
    }
    top++;
    Stack[top] = x;
  } if (isFull()) {
      throw new Error("Over Flow");
    } isFull() isFull {
      throw new Error("Over Flow");
    } throw new Error("Over Flow"); new Error("Over Flow") top++ top Stack[top] = x Stack[top] Stack top x int x x private static int pop() {
    if (isEmpty()) {
      throw new Error("Under Flow");
    }
    top--;
    return Stack[top + 1];
  } pop {
    if (isEmpty()) {
      throw new Error("Under Flow");
    }
    top--;
    return Stack[top + 1];
  } if (isEmpty()) {
      throw new Error("Under Flow");
    } isEmpty() isEmpty {
      throw new Error("Under Flow");
    } throw new Error("Under Flow"); new Error("Under Flow") top-- top return Stack[top + 1]; Stack[top + 1] Stack top + 1 top 1 private static void print(int[] A) {
    System.out.println(Arrays.toString(A));
  } print {
    System.out.println(Arrays.toString(A));
  } System.out.println(Arrays.toString(A)) System.out.println System.out System System.out Arrays.toString(A) Arrays.toString Arrays A int[] A A public class Main {
  static int Max = 1000;
  static int top;
  static int[] Stack = new int[Max];

  public static void main(final String[] args) {
    initialize();
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    String[] str = s.split(" ");
    for (int i = 0; i < str.length; i++) {
      if (Character.isDigit(str[i].charAt(0))) {
        push(Integer.parseInt(str[i]));
      }
      else if (String.valueOf(str[i]).equals("+")) {
        int a = pop();
        int b = pop();
        push(a + b);
      }
      else if (String.valueOf(str[i]).equals("-")) {
        int a = pop();
        int b = pop();
        push(b - a);
      }
      else if (String.valueOf(str[i]).equals("*")) {
        int a = pop();
        int b = pop();
        push(a * b);
      }
    }
    System.out.println(pop());
  }

  private static void initialize() {
    top = 0;
  }

  private static boolean isEmpty() {
    return top == 0;
  }

  private static boolean isFull() {
    return top >= Max - 1;
  }

  private static void push(int x) {
    if (isFull()) {
      throw new Error("Over Flow");
    }
    top++;
    Stack[top] = x;
  }

  private static int pop() {
    if (isEmpty()) {
      throw new Error("Under Flow");
    }
    top--;
    return Stack[top + 1];
  }

  private static void print(int[] A) {
    System.out.println(Arrays.toString(A));
  }
} public class Main {
  static int Max = 1000;
  static int top;
  static int[] Stack = new int[Max];

  public static void main(final String[] args) {
    initialize();
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    String[] str = s.split(" ");
    for (int i = 0; i < str.length; i++) {
      if (Character.isDigit(str[i].charAt(0))) {
        push(Integer.parseInt(str[i]));
      }
      else if (String.valueOf(str[i]).equals("+")) {
        int a = pop();
        int b = pop();
        push(a + b);
      }
      else if (String.valueOf(str[i]).equals("-")) {
        int a = pop();
        int b = pop();
        push(b - a);
      }
      else if (String.valueOf(str[i]).equals("*")) {
        int a = pop();
        int b = pop();
        push(a * b);
      }
    }
    System.out.println(pop());
  }

  private static void initialize() {
    top = 0;
  }

  private static boolean isEmpty() {
    return top == 0;
  }

  private static boolean isFull() {
    return top >= Max - 1;
  }

  private static void push(int x) {
    if (isFull()) {
      throw new Error("Over Flow");
    }
    top++;
    Stack[top] = x;
  }

  private static int pop() {
    if (isEmpty()) {
      throw new Error("Under Flow");
    }
    top--;
    return Stack[top + 1];
  }

  private static void print(int[] A) {
    System.out.println(Arrays.toString(A));
  }
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  static int Max = 1000;
  static int top;
  static int[] Stack = new int[Max];

  public static void main(final String[] args) {
    initialize();
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    String[] str = s.split(" ");
    for (int i = 0; i < str.length; i++) {
      if (Character.isDigit(str[i].charAt(0))) {
        push(Integer.parseInt(str[i]));
      }
      else if (String.valueOf(str[i]).equals("+")) {
        int a = pop();
        int b = pop();
        push(a + b);
      }
      else if (String.valueOf(str[i]).equals("-")) {
        int a = pop();
        int b = pop();
        push(b - a);
      }
      else if (String.valueOf(str[i]).equals("*")) {
        int a = pop();
        int b = pop();
        push(a * b);
      }
    }
    System.out.println(pop());
  }

  private static void initialize() {
    top = 0;
  }

  private static boolean isEmpty() {
    return top == 0;
  }

  private static boolean isFull() {
    return top >= Max - 1;
  }

  private static void push(int x) {
    if (isFull()) {
      throw new Error("Over Flow");
    }
    top++;
    Stack[top] = x;
  }

  private static int pop() {
    if (isEmpty()) {
      throw new Error("Under Flow");
    }
    top--;
    return Stack[top + 1];
  }

  private static void print(int[] A) {
    System.out.println(Arrays.toString(A));
  }
}
