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();
  }
}
 import java.util.Scanner; Scanner java.util import java.util.Deque; Deque java.util import java.util.ArrayDeque; ArrayDeque java.util 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();
  }
} Main public static void main(String... args) {
    Scanner sc = new Scanner(System.in);

    String input = sc.nextLine();

    System.out.println(calc(input));
  } main {
    Scanner sc = new Scanner(System.in);

    String input = sc.nextLine();

    System.out.println(calc(input));
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String input = sc.nextLine(); input sc.nextLine() sc.nextLine sc System.out.println(calc(input)) System.out.println System.out System System.out calc(input) calc input String... args args public static boolean inputIsOperand(String input) {
    try {
      Integer.parseInt(input);
      return true;

    } catch (NumberFormatException e) {
      return false;
    }
  } inputIsOperand {
    try {
      Integer.parseInt(input);
      return true;

    } catch (NumberFormatException e) {
      return false;
    }
  } try {
      Integer.parseInt(input);
      return true;

    } catch (NumberFormatException e) {
      return false;
    } catch (NumberFormatException e) {
      return false;
    } NumberFormatException e {
      return false;
    } return false; false {
      Integer.parseInt(input);
      return true;

    } Integer.parseInt(input) Integer.parseInt Integer input return true; true String input input 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();
  } calc {
    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();
  } Deque<Integer> operand = new ArrayDeque<Integer>(100000); operand new ArrayDeque<Integer>(100000) String[] inputs = input.split(" "); inputs input.split(" ") input.split input " " int operand1 operand1 operand2; operand2 int result = 0; 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));
      }
    } 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));
      }
    } {

      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));
      }
    } 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));
      } str.equals("+") str.equals str "+" {
        operand1 = operand.removeFirst();
        operand2 = operand.removeFirst();
        operand.offerFirst(operand2 + operand1);

      } operand1 = operand.removeFirst() operand1 operand.removeFirst() operand.removeFirst operand operand2 = operand.removeFirst() operand2 operand.removeFirst() operand.removeFirst operand operand.offerFirst(operand2 + operand1) operand.offerFirst operand operand2 + operand1 operand2 operand1 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));
      } str.equals("-") str.equals str "-" {
        operand1 = operand.removeFirst();
        operand2 = operand.removeFirst();
        operand.offerFirst(operand2 - operand1);

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

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

      } operand1 = operand.removeFirst() operand1 operand.removeFirst() operand.removeFirst operand operand2 = operand.removeFirst() operand2 operand.removeFirst() operand.removeFirst operand operand.offerFirst(operand2 * operand1) operand.offerFirst operand operand2 * operand1 operand2 operand1 {
        operand.offerFirst(Integer.parseInt(str));
      } operand.offerFirst(Integer.parseInt(str)) operand.offerFirst operand Integer.parseInt(str) Integer.parseInt Integer str return operand.removeFirst(); operand.removeFirst() operand.removeFirst operand String input input
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();
  }
}

