import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    LinkedList<Integer> stack = new LinkedList<Integer>();
    while(sc.hasNext()){
      String inp = sc.next();
      if('0' <= inp.charAt(0) && inp.charAt(0) <= '9'){
        int num = Integer.parseInt(inp);
        stack.push(num);
      }else{
        int b = stack.pop();
        int a = stack.pop();
        int c;
        if('+' == inp.charAt(0)){
          c = a + b;
        }else if('*' == inp.charAt(0)){
          c = a * b;
        }else{
          c = a - b;
        }
        stack.push(c);
      }
    }

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

    LinkedList<Integer> stack = new LinkedList<Integer>();
    while(sc.hasNext()){
      String inp = sc.next();
      if('0' <= inp.charAt(0) && inp.charAt(0) <= '9'){
        int num = Integer.parseInt(inp);
        stack.push(num);
      }else{
        int b = stack.pop();
        int a = stack.pop();
        int c;
        if('+' == inp.charAt(0)){
          c = a + b;
        }else if('*' == inp.charAt(0)){
          c = a * b;
        }else{
          c = a - b;
        }
        stack.push(c);
      }
    }

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

    LinkedList<Integer> stack = new LinkedList<Integer>();
    while(sc.hasNext()){
      String inp = sc.next();
      if('0' <= inp.charAt(0) && inp.charAt(0) <= '9'){
        int num = Integer.parseInt(inp);
        stack.push(num);
      }else{
        int b = stack.pop();
        int a = stack.pop();
        int c;
        if('+' == inp.charAt(0)){
          c = a + b;
        }else if('*' == inp.charAt(0)){
          c = a * b;
        }else{
          c = a - b;
        }
        stack.push(c);
      }
    }

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

    LinkedList<Integer> stack = new LinkedList<Integer>();
    while(sc.hasNext()){
      String inp = sc.next();
      if('0' <= inp.charAt(0) && inp.charAt(0) <= '9'){
        int num = Integer.parseInt(inp);
        stack.push(num);
      }else{
        int b = stack.pop();
        int a = stack.pop();
        int c;
        if('+' == inp.charAt(0)){
          c = a + b;
        }else if('*' == inp.charAt(0)){
          c = a * b;
        }else{
          c = a - b;
        }
        stack.push(c);
      }
    }

    System.out.println(stack.pop());
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) LinkedList<Integer> stack = new LinkedList<Integer>(); stack new LinkedList<Integer>() while(sc.hasNext()){
      String inp = sc.next();
      if('0' <= inp.charAt(0) && inp.charAt(0) <= '9'){
        int num = Integer.parseInt(inp);
        stack.push(num);
      }else{
        int b = stack.pop();
        int a = stack.pop();
        int c;
        if('+' == inp.charAt(0)){
          c = a + b;
        }else if('*' == inp.charAt(0)){
          c = a * b;
        }else{
          c = a - b;
        }
        stack.push(c);
      }
    } sc.hasNext() sc.hasNext sc {
      String inp = sc.next();
      if('0' <= inp.charAt(0) && inp.charAt(0) <= '9'){
        int num = Integer.parseInt(inp);
        stack.push(num);
      }else{
        int b = stack.pop();
        int a = stack.pop();
        int c;
        if('+' == inp.charAt(0)){
          c = a + b;
        }else if('*' == inp.charAt(0)){
          c = a * b;
        }else{
          c = a - b;
        }
        stack.push(c);
      }
    } String inp = sc.next(); inp sc.next() sc.next sc if('0' <= inp.charAt(0) && inp.charAt(0) <= '9'){
        int num = Integer.parseInt(inp);
        stack.push(num);
      }else{
        int b = stack.pop();
        int a = stack.pop();
        int c;
        if('+' == inp.charAt(0)){
          c = a + b;
        }else if('*' == inp.charAt(0)){
          c = a * b;
        }else{
          c = a - b;
        }
        stack.push(c);
      } '0' <= inp.charAt(0) && inp.charAt(0) <= '9' '0' <= inp.charAt(0) '0' inp.charAt(0) inp.charAt inp 0 inp.charAt(0) <= '9' inp.charAt(0) inp.charAt inp 0 '9' {
        int num = Integer.parseInt(inp);
        stack.push(num);
      } int num = Integer.parseInt(inp); num Integer.parseInt(inp) Integer.parseInt Integer inp stack.push(num) stack.push stack num {
        int b = stack.pop();
        int a = stack.pop();
        int c;
        if('+' == inp.charAt(0)){
          c = a + b;
        }else if('*' == inp.charAt(0)){
          c = a * b;
        }else{
          c = a - b;
        }
        stack.push(c);
      } int b = stack.pop(); b stack.pop() stack.pop stack int a = stack.pop(); a stack.pop() stack.pop stack int c; c if('+' == inp.charAt(0)){
          c = a + b;
        }else if('*' == inp.charAt(0)){
          c = a * b;
        }else{
          c = a - b;
        } '+' == inp.charAt(0) '+' inp.charAt(0) inp.charAt inp 0 {
          c = a + b;
        } c = a + b c a + b a b if('*' == inp.charAt(0)){
          c = a * b;
        }else{
          c = a - b;
        } '*' == inp.charAt(0) '*' inp.charAt(0) inp.charAt inp 0 {
          c = a * b;
        } c = a * b c a * b a b {
          c = a - b;
        } c = a - b c a - b a b stack.push(c) stack.push stack c 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);

    LinkedList<Integer> stack = new LinkedList<Integer>();
    while(sc.hasNext()){
      String inp = sc.next();
      if('0' <= inp.charAt(0) && inp.charAt(0) <= '9'){
        int num = Integer.parseInt(inp);
        stack.push(num);
      }else{
        int b = stack.pop();
        int a = stack.pop();
        int c;
        if('+' == inp.charAt(0)){
          c = a + b;
        }else if('*' == inp.charAt(0)){
          c = a * b;
        }else{
          c = a - b;
        }
        stack.push(c);
      }
    }

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

    LinkedList<Integer> stack = new LinkedList<Integer>();
    while(sc.hasNext()){
      String inp = sc.next();
      if('0' <= inp.charAt(0) && inp.charAt(0) <= '9'){
        int num = Integer.parseInt(inp);
        stack.push(num);
      }else{
        int b = stack.pop();
        int a = stack.pop();
        int c;
        if('+' == inp.charAt(0)){
          c = a + b;
        }else if('*' == inp.charAt(0)){
          c = a * b;
        }else{
          c = a - b;
        }
        stack.push(c);
      }
    }

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

    LinkedList<Integer> stack = new LinkedList<Integer>();
    while(sc.hasNext()){
      String inp = sc.next();
      if('0' <= inp.charAt(0) && inp.charAt(0) <= '9'){
        int num = Integer.parseInt(inp);
        stack.push(num);
      }else{
        int b = stack.pop();
        int a = stack.pop();
        int c;
        if('+' == inp.charAt(0)){
          c = a + b;
        }else if('*' == inp.charAt(0)){
          c = a * b;
        }else{
          c = a - b;
        }
        stack.push(c);
      }
    }

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