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

public class Main {

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

    String[] strs = sc.nextLine().split(" ");

    Deque<String> stack = new ArrayDeque<>();

    long a = 0;
    long b = 0;
  
    for (String s : strs) {
      if (Arrays.asList("+", "-", "*").contains(s)) {
        a = Long.valueOf(stack.pop());
        b = Long.valueOf(stack.pop());
      }

      String r = s;
      if ("+".equals(s)) r = String.valueOf(b + a);
      if ("-".equals(s)) r = String.valueOf(b - a);
      if ("*".equals(s)) r = String.valueOf(b * a);

      stack.push(r);
    }

    System.out.println(stack.pop());
  }
} import java.util.ArrayDeque; ArrayDeque java.util import java.util.Arrays; Arrays java.util import java.util.Deque; Deque java.util import java.util.Scanner; Scanner java.util public class Main {

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

    String[] strs = sc.nextLine().split(" ");

    Deque<String> stack = new ArrayDeque<>();

    long a = 0;
    long b = 0;
  
    for (String s : strs) {
      if (Arrays.asList("+", "-", "*").contains(s)) {
        a = Long.valueOf(stack.pop());
        b = Long.valueOf(stack.pop());
      }

      String r = s;
      if ("+".equals(s)) r = String.valueOf(b + a);
      if ("-".equals(s)) r = String.valueOf(b - a);
      if ("*".equals(s)) r = String.valueOf(b * a);

      stack.push(r);
    }

    System.out.println(stack.pop());
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    String[] strs = sc.nextLine().split(" ");

    Deque<String> stack = new ArrayDeque<>();

    long a = 0;
    long b = 0;
  
    for (String s : strs) {
      if (Arrays.asList("+", "-", "*").contains(s)) {
        a = Long.valueOf(stack.pop());
        b = Long.valueOf(stack.pop());
      }

      String r = s;
      if ("+".equals(s)) r = String.valueOf(b + a);
      if ("-".equals(s)) r = String.valueOf(b - a);
      if ("*".equals(s)) r = String.valueOf(b * a);

      stack.push(r);
    }

    System.out.println(stack.pop());
  } main {
    Scanner sc = new Scanner(System.in);

    String[] strs = sc.nextLine().split(" ");

    Deque<String> stack = new ArrayDeque<>();

    long a = 0;
    long b = 0;
  
    for (String s : strs) {
      if (Arrays.asList("+", "-", "*").contains(s)) {
        a = Long.valueOf(stack.pop());
        b = Long.valueOf(stack.pop());
      }

      String r = s;
      if ("+".equals(s)) r = String.valueOf(b + a);
      if ("-".equals(s)) r = String.valueOf(b - a);
      if ("*".equals(s)) r = String.valueOf(b * a);

      stack.push(r);
    }

    System.out.println(stack.pop());
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String[] strs = sc.nextLine().split(" "); strs sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " Deque<String> stack = new ArrayDeque<>(); stack new ArrayDeque<>() long a = 0; a 0 long b = 0; b 0 for (String s : strs) {
      if (Arrays.asList("+", "-", "*").contains(s)) {
        a = Long.valueOf(stack.pop());
        b = Long.valueOf(stack.pop());
      }

      String r = s;
      if ("+".equals(s)) r = String.valueOf(b + a);
      if ("-".equals(s)) r = String.valueOf(b - a);
      if ("*".equals(s)) r = String.valueOf(b * a);

      stack.push(r);
    } String s strs {
      if (Arrays.asList("+", "-", "*").contains(s)) {
        a = Long.valueOf(stack.pop());
        b = Long.valueOf(stack.pop());
      }

      String r = s;
      if ("+".equals(s)) r = String.valueOf(b + a);
      if ("-".equals(s)) r = String.valueOf(b - a);
      if ("*".equals(s)) r = String.valueOf(b * a);

      stack.push(r);
    } {
      if (Arrays.asList("+", "-", "*").contains(s)) {
        a = Long.valueOf(stack.pop());
        b = Long.valueOf(stack.pop());
      }

      String r = s;
      if ("+".equals(s)) r = String.valueOf(b + a);
      if ("-".equals(s)) r = String.valueOf(b - a);
      if ("*".equals(s)) r = String.valueOf(b * a);

      stack.push(r);
    } if (Arrays.asList("+", "-", "*").contains(s)) {
        a = Long.valueOf(stack.pop());
        b = Long.valueOf(stack.pop());
      } Arrays.asList("+", "-", "*").contains(s) Arrays.asList("+", "-", "*").contains Arrays.asList("+", "-", "*") Arrays.asList Arrays "+" "-" "*" s {
        a = Long.valueOf(stack.pop());
        b = Long.valueOf(stack.pop());
      } a = Long.valueOf(stack.pop()) a Long.valueOf(stack.pop()) Long.valueOf Long stack.pop() stack.pop stack b = Long.valueOf(stack.pop()) b Long.valueOf(stack.pop()) Long.valueOf Long stack.pop() stack.pop stack String r = s; r s if ("+".equals(s)) r = String.valueOf(b + a); "+".equals(s) "+".equals "+" s r = String.valueOf(b + a) r String.valueOf(b + a) String.valueOf String b + a b a if ("-".equals(s)) r = String.valueOf(b - a); "-".equals(s) "-".equals "-" s r = String.valueOf(b - a) r String.valueOf(b - a) String.valueOf String b - a b a if ("*".equals(s)) r = String.valueOf(b * a); "*".equals(s) "*".equals "*" s r = String.valueOf(b * a) r String.valueOf(b * a) String.valueOf String b * a b a stack.push(r) stack.push stack r System.out.println(stack.pop()) System.out.println System.out System System.out stack.pop() stack.pop stack String[] args args public class Main {

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

    String[] strs = sc.nextLine().split(" ");

    Deque<String> stack = new ArrayDeque<>();

    long a = 0;
    long b = 0;
  
    for (String s : strs) {
      if (Arrays.asList("+", "-", "*").contains(s)) {
        a = Long.valueOf(stack.pop());
        b = Long.valueOf(stack.pop());
      }

      String r = s;
      if ("+".equals(s)) r = String.valueOf(b + a);
      if ("-".equals(s)) r = String.valueOf(b - a);
      if ("*".equals(s)) r = String.valueOf(b * a);

      stack.push(r);
    }

    System.out.println(stack.pop());
  }
} public class Main {

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

    String[] strs = sc.nextLine().split(" ");

    Deque<String> stack = new ArrayDeque<>();

    long a = 0;
    long b = 0;
  
    for (String s : strs) {
      if (Arrays.asList("+", "-", "*").contains(s)) {
        a = Long.valueOf(stack.pop());
        b = Long.valueOf(stack.pop());
      }

      String r = s;
      if ("+".equals(s)) r = String.valueOf(b + a);
      if ("-".equals(s)) r = String.valueOf(b - a);
      if ("*".equals(s)) r = String.valueOf(b * a);

      stack.push(r);
    }

    System.out.println(stack.pop());
  }
} Main
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

public class Main {

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

    String[] strs = sc.nextLine().split(" ");

    Deque<String> stack = new ArrayDeque<>();

    long a = 0;
    long b = 0;
  
    for (String s : strs) {
      if (Arrays.asList("+", "-", "*").contains(s)) {
        a = Long.valueOf(stack.pop());
        b = Long.valueOf(stack.pop());
      }

      String r = s;
      if ("+".equals(s)) r = String.valueOf(b + a);
      if ("-".equals(s)) r = String.valueOf(b - a);
      if ("*".equals(s)) r = String.valueOf(b * a);

      stack.push(r);
    }

    System.out.println(stack.pop());
  }
}
