
import java.util.Scanner;

class Main{
  int[] a = new int[200];
  int top;

  Main(){
    top = 0;
  }

  void push(int x){
    a[++top] = x;
  }

  int pop(){
    return a[top--];
  }

  public static void main(String[] args){
    Scanner stdIn = new Scanner(System.in);
    String[] input = stdIn.nextLine().split(" ");
    Main stack = new Main();

    for(int i = 0; i < input.length; i++){
      String s = input[i];

      if(s.equals("+")){
        int a = stack.pop();
        int b = stack.pop();
        stack.push(a + b);
      }
      else if(s.equals("*")){
        int a = stack.pop();
        int b = stack.pop();
        stack.push(a * b);
      }
      else if(s.equals("-")){
        int b = stack.pop();
        int a = stack.pop();
        stack.push(a-b);
      }
      else
        stack.push(Integer.parseInt(s));

    }


    System.out.println(stack.pop());
  }
} import java.util.Scanner; Scanner java.util class Main{
  int[] a = new int[200];
  int top;

  Main(){
    top = 0;
  }

  void push(int x){
    a[++top] = x;
  }

  int pop(){
    return a[top--];
  }

  public static void main(String[] args){
    Scanner stdIn = new Scanner(System.in);
    String[] input = stdIn.nextLine().split(" ");
    Main stack = new Main();

    for(int i = 0; i < input.length; i++){
      String s = input[i];

      if(s.equals("+")){
        int a = stack.pop();
        int b = stack.pop();
        stack.push(a + b);
      }
      else if(s.equals("*")){
        int a = stack.pop();
        int b = stack.pop();
        stack.push(a * b);
      }
      else if(s.equals("-")){
        int b = stack.pop();
        int a = stack.pop();
        stack.push(a-b);
      }
      else
        stack.push(Integer.parseInt(s));

    }


    System.out.println(stack.pop());
  }
} Main int[] a = new int[200]; a new int[200] 200 int top; top Main(){
    top = 0;
  } Main {
    top = 0;
  } top = 0 top 0 void push(int x){
    a[++top] = x;
  } push {
    a[++top] = x;
  } a[++top] = x a[++top] a ++top top x int x x int pop(){
    return a[top--];
  } pop {
    return a[top--];
  } return a[top--]; a[top--] a top-- top public static void main(String[] args){
    Scanner stdIn = new Scanner(System.in);
    String[] input = stdIn.nextLine().split(" ");
    Main stack = new Main();

    for(int i = 0; i < input.length; i++){
      String s = input[i];

      if(s.equals("+")){
        int a = stack.pop();
        int b = stack.pop();
        stack.push(a + b);
      }
      else if(s.equals("*")){
        int a = stack.pop();
        int b = stack.pop();
        stack.push(a * b);
      }
      else if(s.equals("-")){
        int b = stack.pop();
        int a = stack.pop();
        stack.push(a-b);
      }
      else
        stack.push(Integer.parseInt(s));

    }


    System.out.println(stack.pop());
  } main {
    Scanner stdIn = new Scanner(System.in);
    String[] input = stdIn.nextLine().split(" ");
    Main stack = new Main();

    for(int i = 0; i < input.length; i++){
      String s = input[i];

      if(s.equals("+")){
        int a = stack.pop();
        int b = stack.pop();
        stack.push(a + b);
      }
      else if(s.equals("*")){
        int a = stack.pop();
        int b = stack.pop();
        stack.push(a * b);
      }
      else if(s.equals("-")){
        int b = stack.pop();
        int a = stack.pop();
        stack.push(a-b);
      }
      else
        stack.push(Integer.parseInt(s));

    }


    System.out.println(stack.pop());
  } Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) String[] input = stdIn.nextLine().split(" "); input stdIn.nextLine().split(" ") stdIn.nextLine().split stdIn.nextLine() stdIn.nextLine stdIn " " Main stack = new Main(); stack new Main() for(int i = 0; i < input.length; i++){
      String s = input[i];

      if(s.equals("+")){
        int a = stack.pop();
        int b = stack.pop();
        stack.push(a + b);
      }
      else if(s.equals("*")){
        int a = stack.pop();
        int b = stack.pop();
        stack.push(a * b);
      }
      else if(s.equals("-")){
        int b = stack.pop();
        int a = stack.pop();
        stack.push(a-b);
      }
      else
        stack.push(Integer.parseInt(s));

    } int i = 0; int i = 0; i 0 i < input.length i input.length input input.length i++ i++ i {
      String s = input[i];

      if(s.equals("+")){
        int a = stack.pop();
        int b = stack.pop();
        stack.push(a + b);
      }
      else if(s.equals("*")){
        int a = stack.pop();
        int b = stack.pop();
        stack.push(a * b);
      }
      else if(s.equals("-")){
        int b = stack.pop();
        int a = stack.pop();
        stack.push(a-b);
      }
      else
        stack.push(Integer.parseInt(s));

    } {
      String s = input[i];

      if(s.equals("+")){
        int a = stack.pop();
        int b = stack.pop();
        stack.push(a + b);
      }
      else if(s.equals("*")){
        int a = stack.pop();
        int b = stack.pop();
        stack.push(a * b);
      }
      else if(s.equals("-")){
        int b = stack.pop();
        int a = stack.pop();
        stack.push(a-b);
      }
      else
        stack.push(Integer.parseInt(s));

    } String s = input[i]; s input[i] input i if(s.equals("+")){
        int a = stack.pop();
        int b = stack.pop();
        stack.push(a + b);
      }
      else if(s.equals("*")){
        int a = stack.pop();
        int b = stack.pop();
        stack.push(a * b);
      }
      else if(s.equals("-")){
        int b = stack.pop();
        int a = stack.pop();
        stack.push(a-b);
      }
      else
        stack.push(Integer.parseInt(s)); s.equals("+") s.equals s "+" {
        int a = stack.pop();
        int b = stack.pop();
        stack.push(a + b);
      } int a = stack.pop(); a stack.pop() stack.pop stack int b = stack.pop(); b stack.pop() stack.pop stack stack.push(a + b) stack.push stack a + b a b if(s.equals("*")){
        int a = stack.pop();
        int b = stack.pop();
        stack.push(a * b);
      }
      else if(s.equals("-")){
        int b = stack.pop();
        int a = stack.pop();
        stack.push(a-b);
      }
      else
        stack.push(Integer.parseInt(s)); s.equals("*") s.equals s "*" {
        int a = stack.pop();
        int b = stack.pop();
        stack.push(a * b);
      } int a = stack.pop(); a stack.pop() stack.pop stack int b = stack.pop(); b stack.pop() stack.pop stack stack.push(a * b) stack.push stack a * b a b if(s.equals("-")){
        int b = stack.pop();
        int a = stack.pop();
        stack.push(a-b);
      }
      else
        stack.push(Integer.parseInt(s)); s.equals("-") s.equals s "-" {
        int b = stack.pop();
        int a = stack.pop();
        stack.push(a-b);
      } int b = stack.pop(); b stack.pop() stack.pop stack int a = stack.pop(); a stack.pop() stack.pop stack stack.push(a-b) stack.push stack a-b a b stack.push(Integer.parseInt(s)) stack.push stack Integer.parseInt(s) Integer.parseInt Integer s System.out.println(stack.pop()) System.out.println System.out System System.out stack.pop() stack.pop stack String[] args args

import java.util.Scanner;

class Main{
  int[] a = new int[200];
  int top;

  Main(){
    top = 0;
  }

  void push(int x){
    a[++top] = x;
  }

  int pop(){
    return a[top--];
  }

  public static void main(String[] args){
    Scanner stdIn = new Scanner(System.in);
    String[] input = stdIn.nextLine().split(" ");
    Main stack = new Main();

    for(int i = 0; i < input.length; i++){
      String s = input[i];

      if(s.equals("+")){
        int a = stack.pop();
        int b = stack.pop();
        stack.push(a + b);
      }
      else if(s.equals("*")){
        int a = stack.pop();
        int b = stack.pop();
        stack.push(a * b);
      }
      else if(s.equals("-")){
        int b = stack.pop();
        int a = stack.pop();
        stack.push(a-b);
      }
      else
        stack.push(Integer.parseInt(s));

    }


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