import java.io.*;
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] line = br.readLine().split(" ");
    Stack<String> stack = new Stack<String>();

    for(int i = 0; i < line.length; i++){
      if(isNumber(line[i])){
          stack.push(line[i]);
      }else{
        int b = Integer.parseInt(stack.pop());
        int a = Integer.parseInt(stack.pop());  
        if(line[i].equals("+")){
          stack.push(String.valueOf(a+b));
        }else if(line[i].equals("-")){
            stack.push(String.valueOf(a-b));
        }else if(line[i].equals("*")){
            stack.push(String.valueOf(a*b));
        }else if(line[i].equals("/")){
            stack.push(String.valueOf(a/b));
        }
      }
    }

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

  public static boolean isNumber(String term) {
      Pattern patternNum = Pattern.compile("-*[0-9]+");
      Matcher matcherNum = patternNum.matcher(term);

      return matcherNum.matches();
  }
} import java.io.*; io.* java import java.util.*; util.* java import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Stack; Stack java.util import java.util.regex.Matcher; Matcher java.util.regex import java.util.regex.Pattern; Pattern java.util.regex public class Main{
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] line = br.readLine().split(" ");
    Stack<String> stack = new Stack<String>();

    for(int i = 0; i < line.length; i++){
      if(isNumber(line[i])){
          stack.push(line[i]);
      }else{
        int b = Integer.parseInt(stack.pop());
        int a = Integer.parseInt(stack.pop());  
        if(line[i].equals("+")){
          stack.push(String.valueOf(a+b));
        }else if(line[i].equals("-")){
            stack.push(String.valueOf(a-b));
        }else if(line[i].equals("*")){
            stack.push(String.valueOf(a*b));
        }else if(line[i].equals("/")){
            stack.push(String.valueOf(a/b));
        }
      }
    }

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

  public static boolean isNumber(String term) {
      Pattern patternNum = Pattern.compile("-*[0-9]+");
      Matcher matcherNum = patternNum.matcher(term);

      return matcherNum.matches();
  }
} Main public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] line = br.readLine().split(" ");
    Stack<String> stack = new Stack<String>();

    for(int i = 0; i < line.length; i++){
      if(isNumber(line[i])){
          stack.push(line[i]);
      }else{
        int b = Integer.parseInt(stack.pop());
        int a = Integer.parseInt(stack.pop());  
        if(line[i].equals("+")){
          stack.push(String.valueOf(a+b));
        }else if(line[i].equals("-")){
            stack.push(String.valueOf(a-b));
        }else if(line[i].equals("*")){
            stack.push(String.valueOf(a*b));
        }else if(line[i].equals("/")){
            stack.push(String.valueOf(a/b));
        }
      }
    }

    System.out.println(stack.pop());
  } main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] line = br.readLine().split(" ");
    Stack<String> stack = new Stack<String>();

    for(int i = 0; i < line.length; i++){
      if(isNumber(line[i])){
          stack.push(line[i]);
      }else{
        int b = Integer.parseInt(stack.pop());
        int a = Integer.parseInt(stack.pop());  
        if(line[i].equals("+")){
          stack.push(String.valueOf(a+b));
        }else if(line[i].equals("-")){
            stack.push(String.valueOf(a-b));
        }else if(line[i].equals("*")){
            stack.push(String.valueOf(a*b));
        }else if(line[i].equals("/")){
            stack.push(String.valueOf(a/b));
        }
      }
    }

    System.out.println(stack.pop());
  } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] line = br.readLine().split(" "); line br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " Stack<String> stack = new Stack<String>(); stack new Stack<String>() for(int i = 0; i < line.length; i++){
      if(isNumber(line[i])){
          stack.push(line[i]);
      }else{
        int b = Integer.parseInt(stack.pop());
        int a = Integer.parseInt(stack.pop());  
        if(line[i].equals("+")){
          stack.push(String.valueOf(a+b));
        }else if(line[i].equals("-")){
            stack.push(String.valueOf(a-b));
        }else if(line[i].equals("*")){
            stack.push(String.valueOf(a*b));
        }else if(line[i].equals("/")){
            stack.push(String.valueOf(a/b));
        }
      }
    } int i = 0; int i = 0; i 0 i < line.length i line.length line line.length i++ i++ i {
      if(isNumber(line[i])){
          stack.push(line[i]);
      }else{
        int b = Integer.parseInt(stack.pop());
        int a = Integer.parseInt(stack.pop());  
        if(line[i].equals("+")){
          stack.push(String.valueOf(a+b));
        }else if(line[i].equals("-")){
            stack.push(String.valueOf(a-b));
        }else if(line[i].equals("*")){
            stack.push(String.valueOf(a*b));
        }else if(line[i].equals("/")){
            stack.push(String.valueOf(a/b));
        }
      }
    } {
      if(isNumber(line[i])){
          stack.push(line[i]);
      }else{
        int b = Integer.parseInt(stack.pop());
        int a = Integer.parseInt(stack.pop());  
        if(line[i].equals("+")){
          stack.push(String.valueOf(a+b));
        }else if(line[i].equals("-")){
            stack.push(String.valueOf(a-b));
        }else if(line[i].equals("*")){
            stack.push(String.valueOf(a*b));
        }else if(line[i].equals("/")){
            stack.push(String.valueOf(a/b));
        }
      }
    } if(isNumber(line[i])){
          stack.push(line[i]);
      }else{
        int b = Integer.parseInt(stack.pop());
        int a = Integer.parseInt(stack.pop());  
        if(line[i].equals("+")){
          stack.push(String.valueOf(a+b));
        }else if(line[i].equals("-")){
            stack.push(String.valueOf(a-b));
        }else if(line[i].equals("*")){
            stack.push(String.valueOf(a*b));
        }else if(line[i].equals("/")){
            stack.push(String.valueOf(a/b));
        }
      } isNumber(line[i]) isNumber line[i] line i {
          stack.push(line[i]);
      } stack.push(line[i]) stack.push stack line[i] line i {
        int b = Integer.parseInt(stack.pop());
        int a = Integer.parseInt(stack.pop());  
        if(line[i].equals("+")){
          stack.push(String.valueOf(a+b));
        }else if(line[i].equals("-")){
            stack.push(String.valueOf(a-b));
        }else if(line[i].equals("*")){
            stack.push(String.valueOf(a*b));
        }else if(line[i].equals("/")){
            stack.push(String.valueOf(a/b));
        }
      } int b = Integer.parseInt(stack.pop()); b Integer.parseInt(stack.pop()) Integer.parseInt Integer stack.pop() stack.pop stack int a = Integer.parseInt(stack.pop()); a Integer.parseInt(stack.pop()) Integer.parseInt Integer stack.pop() stack.pop stack if(line[i].equals("+")){
          stack.push(String.valueOf(a+b));
        }else if(line[i].equals("-")){
            stack.push(String.valueOf(a-b));
        }else if(line[i].equals("*")){
            stack.push(String.valueOf(a*b));
        }else if(line[i].equals("/")){
            stack.push(String.valueOf(a/b));
        } line[i].equals("+") line[i].equals line[i] line i "+" {
          stack.push(String.valueOf(a+b));
        } stack.push(String.valueOf(a+b)) stack.push stack String.valueOf(a+b) String.valueOf String a+b a b if(line[i].equals("-")){
            stack.push(String.valueOf(a-b));
        }else if(line[i].equals("*")){
            stack.push(String.valueOf(a*b));
        }else if(line[i].equals("/")){
            stack.push(String.valueOf(a/b));
        } line[i].equals("-") line[i].equals line[i] line i "-" {
            stack.push(String.valueOf(a-b));
        } stack.push(String.valueOf(a-b)) stack.push stack String.valueOf(a-b) String.valueOf String a-b a b if(line[i].equals("*")){
            stack.push(String.valueOf(a*b));
        }else if(line[i].equals("/")){
            stack.push(String.valueOf(a/b));
        } line[i].equals("*") line[i].equals line[i] line i "*" {
            stack.push(String.valueOf(a*b));
        } stack.push(String.valueOf(a*b)) stack.push stack String.valueOf(a*b) String.valueOf String a*b a b if(line[i].equals("/")){
            stack.push(String.valueOf(a/b));
        } line[i].equals("/") line[i].equals line[i] line i "/" {
            stack.push(String.valueOf(a/b));
        } stack.push(String.valueOf(a/b)) stack.push stack String.valueOf(a/b) String.valueOf String a/b a b System.out.println(stack.pop()) System.out.println System.out System System.out stack.pop() stack.pop stack String[] args args public static boolean isNumber(String term) {
      Pattern patternNum = Pattern.compile("-*[0-9]+");
      Matcher matcherNum = patternNum.matcher(term);

      return matcherNum.matches();
  } isNumber {
      Pattern patternNum = Pattern.compile("-*[0-9]+");
      Matcher matcherNum = patternNum.matcher(term);

      return matcherNum.matches();
  } Pattern patternNum = Pattern.compile("-*[0-9]+"); patternNum Pattern.compile("-*[0-9]+") Pattern.compile Pattern "-*[0-9]+" Matcher matcherNum = patternNum.matcher(term); matcherNum patternNum.matcher(term) patternNum.matcher patternNum term return matcherNum.matches(); matcherNum.matches() matcherNum.matches matcherNum String term term public class Main{
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] line = br.readLine().split(" ");
    Stack<String> stack = new Stack<String>();

    for(int i = 0; i < line.length; i++){
      if(isNumber(line[i])){
          stack.push(line[i]);
      }else{
        int b = Integer.parseInt(stack.pop());
        int a = Integer.parseInt(stack.pop());  
        if(line[i].equals("+")){
          stack.push(String.valueOf(a+b));
        }else if(line[i].equals("-")){
            stack.push(String.valueOf(a-b));
        }else if(line[i].equals("*")){
            stack.push(String.valueOf(a*b));
        }else if(line[i].equals("/")){
            stack.push(String.valueOf(a/b));
        }
      }
    }

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

  public static boolean isNumber(String term) {
      Pattern patternNum = Pattern.compile("-*[0-9]+");
      Matcher matcherNum = patternNum.matcher(term);

      return matcherNum.matches();
  }
} public class Main{
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] line = br.readLine().split(" ");
    Stack<String> stack = new Stack<String>();

    for(int i = 0; i < line.length; i++){
      if(isNumber(line[i])){
          stack.push(line[i]);
      }else{
        int b = Integer.parseInt(stack.pop());
        int a = Integer.parseInt(stack.pop());  
        if(line[i].equals("+")){
          stack.push(String.valueOf(a+b));
        }else if(line[i].equals("-")){
            stack.push(String.valueOf(a-b));
        }else if(line[i].equals("*")){
            stack.push(String.valueOf(a*b));
        }else if(line[i].equals("/")){
            stack.push(String.valueOf(a/b));
        }
      }
    }

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

  public static boolean isNumber(String term) {
      Pattern patternNum = Pattern.compile("-*[0-9]+");
      Matcher matcherNum = patternNum.matcher(term);

      return matcherNum.matches();
  }
} Main
import java.io.*;
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] line = br.readLine().split(" ");
    Stack<String> stack = new Stack<String>();

    for(int i = 0; i < line.length; i++){
      if(isNumber(line[i])){
          stack.push(line[i]);
      }else{
        int b = Integer.parseInt(stack.pop());
        int a = Integer.parseInt(stack.pop());  
        if(line[i].equals("+")){
          stack.push(String.valueOf(a+b));
        }else if(line[i].equals("-")){
            stack.push(String.valueOf(a-b));
        }else if(line[i].equals("*")){
            stack.push(String.valueOf(a*b));
        }else if(line[i].equals("/")){
            stack.push(String.valueOf(a/b));
        }
      }
    }

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

  public static boolean isNumber(String term) {
      Pattern patternNum = Pattern.compile("-*[0-9]+");
      Matcher matcherNum = patternNum.matcher(term);

      return matcherNum.matches();
  }
}