import java.util.Scanner;
import java.util.Deque;
import java.util.ArrayDeque;

class Main {
  public static void main(String... args) {
    Scanner sc = new Scanner(System.in);

    String input = sc.nextLine();

    System.out.println(calc(input));
  }

  public static boolean inputIsOperand(String input) {
    try {
      Integer.parseInt(input);
      return true;

    } catch (NumberFormatException e) {
      return false;
    }
  }

  public static int calc(String input) {
    Deque<Integer> operand = new ArrayDeque<Integer>(100000);
    String[] inputs = input.split(" ");

    int operand1, operand2;
    int result = 0;

    for (String str : inputs) {

      if (str.equals("+")) {
        operand1 = operand.removeFirst();
        operand2 = operand.removeFirst();
        operand.offerFirst(operand2 + operand1);

      } else if (str.equals("-")) {
        operand1 = operand.removeFirst();
        operand2 = operand.removeFirst();
        operand.offerFirst(operand2 - operand1);

      } else if (str.equals("*")) {
        operand1 = operand.removeFirst();
        operand2 = operand.removeFirst();
        operand.offerFirst(operand2 * operand1);

      } else {
        operand.offerFirst(Integer.parseInt(str));
      }
    }

    return operand.removeFirst();
  }
}


/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz