import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int j = 0;
    int a, b;

    String input = sc.nextLine();
    //System.out.println(input);

    String[] s = input.split(" ",0);
    int len = s.length;

    int[] stack = new int[len];

    for (int i = 0; i < len; i++) {
      if(s[i].equals("+")){
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a+b;
        j = j-1;
      }
      else if(s[i].equals("-")){
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a-b;
        j = j-1;
      }
      else if(s[i].equals("*")){
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a*b;
        j = j-1;
      }
      else{
        a = Integer.parseInt(s[i]);
        stack[j] = a;
        j=j+1;
      }
    }
    System.out.println(stack[0]);
  }
} import java.util.Scanner; Scanner java.util class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int j = 0;
    int a, b;

    String input = sc.nextLine();
    //System.out.println(input);

    String[] s = input.split(" ",0);
    int len = s.length;

    int[] stack = new int[len];

    for (int i = 0; i < len; i++) {
      if(s[i].equals("+")){
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a+b;
        j = j-1;
      }
      else if(s[i].equals("-")){
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a-b;
        j = j-1;
      }
      else if(s[i].equals("*")){
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a*b;
        j = j-1;
      }
      else{
        a = Integer.parseInt(s[i]);
        stack[j] = a;
        j=j+1;
      }
    }
    System.out.println(stack[0]);
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int j = 0;
    int a, b;

    String input = sc.nextLine();
    //System.out.println(input);

    String[] s = input.split(" ",0);
    int len = s.length;

    int[] stack = new int[len];

    for (int i = 0; i < len; i++) {
      if(s[i].equals("+")){
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a+b;
        j = j-1;
      }
      else if(s[i].equals("-")){
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a-b;
        j = j-1;
      }
      else if(s[i].equals("*")){
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a*b;
        j = j-1;
      }
      else{
        a = Integer.parseInt(s[i]);
        stack[j] = a;
        j=j+1;
      }
    }
    System.out.println(stack[0]);
  } main {
    Scanner sc = new Scanner(System.in);
    int j = 0;
    int a, b;

    String input = sc.nextLine();
    //System.out.println(input);

    String[] s = input.split(" ",0);
    int len = s.length;

    int[] stack = new int[len];

    for (int i = 0; i < len; i++) {
      if(s[i].equals("+")){
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a+b;
        j = j-1;
      }
      else if(s[i].equals("-")){
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a-b;
        j = j-1;
      }
      else if(s[i].equals("*")){
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a*b;
        j = j-1;
      }
      else{
        a = Integer.parseInt(s[i]);
        stack[j] = a;
        j=j+1;
      }
    }
    System.out.println(stack[0]);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int j = 0; j 0 int a a b; b String input = sc.nextLine(); input sc.nextLine() sc.nextLine sc String[] s = input.split(" ",0); s input.split(" ",0) input.split input " " 0 int len = s.length; len s.length s s.length int[] stack = new int[len]; stack new int[len] len for (int i = 0; i < len; i++) {
      if(s[i].equals("+")){
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a+b;
        j = j-1;
      }
      else if(s[i].equals("-")){
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a-b;
        j = j-1;
      }
      else if(s[i].equals("*")){
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a*b;
        j = j-1;
      }
      else{
        a = Integer.parseInt(s[i]);
        stack[j] = a;
        j=j+1;
      }
    } int i = 0; int i = 0; i 0 i < len i len i++ i++ i {
      if(s[i].equals("+")){
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a+b;
        j = j-1;
      }
      else if(s[i].equals("-")){
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a-b;
        j = j-1;
      }
      else if(s[i].equals("*")){
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a*b;
        j = j-1;
      }
      else{
        a = Integer.parseInt(s[i]);
        stack[j] = a;
        j=j+1;
      }
    } {
      if(s[i].equals("+")){
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a+b;
        j = j-1;
      }
      else if(s[i].equals("-")){
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a-b;
        j = j-1;
      }
      else if(s[i].equals("*")){
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a*b;
        j = j-1;
      }
      else{
        a = Integer.parseInt(s[i]);
        stack[j] = a;
        j=j+1;
      }
    } if(s[i].equals("+")){
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a+b;
        j = j-1;
      }
      else if(s[i].equals("-")){
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a-b;
        j = j-1;
      }
      else if(s[i].equals("*")){
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a*b;
        j = j-1;
      }
      else{
        a = Integer.parseInt(s[i]);
        stack[j] = a;
        j=j+1;
      } s[i].equals("+") s[i].equals s[i] s i "+" {
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a+b;
        j = j-1;
      } a = stack[j-2] a stack[j-2] stack j-2 j 2 b = stack[j-1] b stack[j-1] stack j-1 j 1 stack[j-2] = a+b stack[j-2] stack j-2 j 2 a+b a b j = j-1 j j-1 j 1 if(s[i].equals("-")){
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a-b;
        j = j-1;
      }
      else if(s[i].equals("*")){
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a*b;
        j = j-1;
      }
      else{
        a = Integer.parseInt(s[i]);
        stack[j] = a;
        j=j+1;
      } s[i].equals("-") s[i].equals s[i] s i "-" {
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a-b;
        j = j-1;
      } a = stack[j-2] a stack[j-2] stack j-2 j 2 b = stack[j-1] b stack[j-1] stack j-1 j 1 stack[j-2] = a-b stack[j-2] stack j-2 j 2 a-b a b j = j-1 j j-1 j 1 if(s[i].equals("*")){
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a*b;
        j = j-1;
      }
      else{
        a = Integer.parseInt(s[i]);
        stack[j] = a;
        j=j+1;
      } s[i].equals("*") s[i].equals s[i] s i "*" {
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a*b;
        j = j-1;
      } a = stack[j-2] a stack[j-2] stack j-2 j 2 b = stack[j-1] b stack[j-1] stack j-1 j 1 stack[j-2] = a*b stack[j-2] stack j-2 j 2 a*b a b j = j-1 j j-1 j 1 {
        a = Integer.parseInt(s[i]);
        stack[j] = a;
        j=j+1;
      } a = Integer.parseInt(s[i]) a Integer.parseInt(s[i]) Integer.parseInt Integer s[i] s i stack[j] = a stack[j] stack j a j=j+1 j j+1 j 1 System.out.println(stack[0]) System.out.println System.out System System.out stack[0] stack 0 String[] args args
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int j = 0;
    int a, b;

    String input = sc.nextLine();
    //System.out.println(input);

    String[] s = input.split(" ",0);
    int len = s.length;

    int[] stack = new int[len];

    for (int i = 0; i < len; i++) {
      if(s[i].equals("+")){
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a+b;
        j = j-1;
      }
      else if(s[i].equals("-")){
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a-b;
        j = j-1;
      }
      else if(s[i].equals("*")){
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a*b;
        j = j-1;
      }
      else{
        a = Integer.parseInt(s[i]);
        stack[j] = a;
        j=j+1;
      }
    }
    System.out.println(stack[0]);
  }
}
