import java.util.*;

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

    int result = 0;
    
    Stack<Integer> numbers = new Stack<Integer>();
    
    for (int i = 0; i < input.length; i++) {
      try {
        numbers.push(Integer.parseInt(input[i]));
      } catch(Exception e) {
        //pop last two from stack and compute
        int second = numbers.pop();
        int first = numbers.pop();
        
        // evaluate based on operator
        if (input[i].equals("+")) {
          result = first + second;
        } else if (input[i].equals("-")) {
          result = first - second;
        } else {
          result = first * second;
        }
        numbers.push(result);
      }
    }
    // print results
    System.out.println(result);
  }
} import java.util.*; util.* java public class Main{
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    String[] input = in.nextLine().split(" ");
    in.close();

    int result = 0;
    
    Stack<Integer> numbers = new Stack<Integer>();
    
    for (int i = 0; i < input.length; i++) {
      try {
        numbers.push(Integer.parseInt(input[i]));
      } catch(Exception e) {
        //pop last two from stack and compute
        int second = numbers.pop();
        int first = numbers.pop();
        
        // evaluate based on operator
        if (input[i].equals("+")) {
          result = first + second;
        } else if (input[i].equals("-")) {
          result = first - second;
        } else {
          result = first * second;
        }
        numbers.push(result);
      }
    }
    // print results
    System.out.println(result);
  }
} Main public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    String[] input = in.nextLine().split(" ");
    in.close();

    int result = 0;
    
    Stack<Integer> numbers = new Stack<Integer>();
    
    for (int i = 0; i < input.length; i++) {
      try {
        numbers.push(Integer.parseInt(input[i]));
      } catch(Exception e) {
        //pop last two from stack and compute
        int second = numbers.pop();
        int first = numbers.pop();
        
        // evaluate based on operator
        if (input[i].equals("+")) {
          result = first + second;
        } else if (input[i].equals("-")) {
          result = first - second;
        } else {
          result = first * second;
        }
        numbers.push(result);
      }
    }
    // print results
    System.out.println(result);
  } main {
    Scanner in = new Scanner(System.in);
    String[] input = in.nextLine().split(" ");
    in.close();

    int result = 0;
    
    Stack<Integer> numbers = new Stack<Integer>();
    
    for (int i = 0; i < input.length; i++) {
      try {
        numbers.push(Integer.parseInt(input[i]));
      } catch(Exception e) {
        //pop last two from stack and compute
        int second = numbers.pop();
        int first = numbers.pop();
        
        // evaluate based on operator
        if (input[i].equals("+")) {
          result = first + second;
        } else if (input[i].equals("-")) {
          result = first - second;
        } else {
          result = first * second;
        }
        numbers.push(result);
      }
    }
    // print results
    System.out.println(result);
  } Scanner in = new Scanner(System.in); in new Scanner(System.in) String[] input = in.nextLine().split(" "); input in.nextLine().split(" ") in.nextLine().split in.nextLine() in.nextLine in " " in.close() in.close in int result = 0; result 0 Stack<Integer> numbers = new Stack<Integer>(); numbers new Stack<Integer>() for (int i = 0; i < input.length; i++) {
      try {
        numbers.push(Integer.parseInt(input[i]));
      } catch(Exception e) {
        //pop last two from stack and compute
        int second = numbers.pop();
        int first = numbers.pop();
        
        // evaluate based on operator
        if (input[i].equals("+")) {
          result = first + second;
        } else if (input[i].equals("-")) {
          result = first - second;
        } else {
          result = first * second;
        }
        numbers.push(result);
      }
    } int i = 0; int i = 0; i 0 i < input.length i input.length input input.length i++ i++ i {
      try {
        numbers.push(Integer.parseInt(input[i]));
      } catch(Exception e) {
        //pop last two from stack and compute
        int second = numbers.pop();
        int first = numbers.pop();
        
        // evaluate based on operator
        if (input[i].equals("+")) {
          result = first + second;
        } else if (input[i].equals("-")) {
          result = first - second;
        } else {
          result = first * second;
        }
        numbers.push(result);
      }
    } {
      try {
        numbers.push(Integer.parseInt(input[i]));
      } catch(Exception e) {
        //pop last two from stack and compute
        int second = numbers.pop();
        int first = numbers.pop();
        
        // evaluate based on operator
        if (input[i].equals("+")) {
          result = first + second;
        } else if (input[i].equals("-")) {
          result = first - second;
        } else {
          result = first * second;
        }
        numbers.push(result);
      }
    } try {
        numbers.push(Integer.parseInt(input[i]));
      } catch(Exception e) {
        //pop last two from stack and compute
        int second = numbers.pop();
        int first = numbers.pop();
        
        // evaluate based on operator
        if (input[i].equals("+")) {
          result = first + second;
        } else if (input[i].equals("-")) {
          result = first - second;
        } else {
          result = first * second;
        }
        numbers.push(result);
      } catch(Exception e) {
        //pop last two from stack and compute
        int second = numbers.pop();
        int first = numbers.pop();
        
        // evaluate based on operator
        if (input[i].equals("+")) {
          result = first + second;
        } else if (input[i].equals("-")) {
          result = first - second;
        } else {
          result = first * second;
        }
        numbers.push(result);
      } Exception e {
        //pop last two from stack and compute
        int second = numbers.pop();
        int first = numbers.pop();
        
        // evaluate based on operator
        if (input[i].equals("+")) {
          result = first + second;
        } else if (input[i].equals("-")) {
          result = first - second;
        } else {
          result = first * second;
        }
        numbers.push(result);
      } int second = numbers.pop(); second numbers.pop() numbers.pop numbers int first = numbers.pop(); first numbers.pop() numbers.pop numbers if (input[i].equals("+")) {
          result = first + second;
        } else if (input[i].equals("-")) {
          result = first - second;
        } else {
          result = first * second;
        } input[i].equals("+") input[i].equals input[i] input i "+" {
          result = first + second;
        } result = first + second result first + second first second if (input[i].equals("-")) {
          result = first - second;
        } else {
          result = first * second;
        } input[i].equals("-") input[i].equals input[i] input i "-" {
          result = first - second;
        } result = first - second result first - second first second {
          result = first * second;
        } result = first * second result first * second first second numbers.push(result) numbers.push numbers result {
        numbers.push(Integer.parseInt(input[i]));
      } numbers.push(Integer.parseInt(input[i])) numbers.push numbers Integer.parseInt(input[i]) Integer.parseInt Integer input[i] input i System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main{
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    String[] input = in.nextLine().split(" ");
    in.close();

    int result = 0;
    
    Stack<Integer> numbers = new Stack<Integer>();
    
    for (int i = 0; i < input.length; i++) {
      try {
        numbers.push(Integer.parseInt(input[i]));
      } catch(Exception e) {
        //pop last two from stack and compute
        int second = numbers.pop();
        int first = numbers.pop();
        
        // evaluate based on operator
        if (input[i].equals("+")) {
          result = first + second;
        } else if (input[i].equals("-")) {
          result = first - second;
        } else {
          result = first * second;
        }
        numbers.push(result);
      }
    }
    // print results
    System.out.println(result);
  }
} public class Main{
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    String[] input = in.nextLine().split(" ");
    in.close();

    int result = 0;
    
    Stack<Integer> numbers = new Stack<Integer>();
    
    for (int i = 0; i < input.length; i++) {
      try {
        numbers.push(Integer.parseInt(input[i]));
      } catch(Exception e) {
        //pop last two from stack and compute
        int second = numbers.pop();
        int first = numbers.pop();
        
        // evaluate based on operator
        if (input[i].equals("+")) {
          result = first + second;
        } else if (input[i].equals("-")) {
          result = first - second;
        } else {
          result = first * second;
        }
        numbers.push(result);
      }
    }
    // print results
    System.out.println(result);
  }
} Main
import java.util.*;

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

    int result = 0;
    
    Stack<Integer> numbers = new Stack<Integer>();
    
    for (int i = 0; i < input.length; i++) {
      try {
        numbers.push(Integer.parseInt(input[i]));
      } catch(Exception e) {
        //pop last two from stack and compute
        int second = numbers.pop();
        int first = numbers.pop();
        
        // evaluate based on operator
        if (input[i].equals("+")) {
          result = first + second;
        } else if (input[i].equals("-")) {
          result = first - second;
        } else {
          result = first * second;
        }
        numbers.push(result);
      }
    }
    // print results
    System.out.println(result);
  }
}
