import java.io.*;
import java.util.*;

class Main{
  public static void main(String[] args)throws java.lang.NumberFormatException{
    Scanner scan=new Scanner(System.in);
    Deque<Integer> stack=new ArrayDeque<>();

    while(scan.hasNext()){
      String op=scan.next();
      if(isNum(op)){
        stack.addFirst(Integer.parseInt(op));
      }else if(op.equals("+")){
        int x=stack.removeFirst();
        int y=stack.removeFirst();
        stack.addFirst(y+x);
      }else if(op.equals("-")){
        int x=stack.removeFirst();
        int y=stack.removeFirst();
        stack.addFirst(y-x);
      }else if(op.equals("*")){
        int x=stack.removeFirst();
        int y=stack.removeFirst();
        stack.addFirst(y*x);
      }
    }

    System.out.println(stack.removeFirst());
  }
  static boolean isNum(String s){
    try{
      Integer.parseInt(s);
      return true;
    }catch(NumberFormatException e){
      return false;
    }
  }
} import java.io.*; io.* java import java.util.*; util.* java class Main{
  public static void main(String[] args)throws java.lang.NumberFormatException{
    Scanner scan=new Scanner(System.in);
    Deque<Integer> stack=new ArrayDeque<>();

    while(scan.hasNext()){
      String op=scan.next();
      if(isNum(op)){
        stack.addFirst(Integer.parseInt(op));
      }else if(op.equals("+")){
        int x=stack.removeFirst();
        int y=stack.removeFirst();
        stack.addFirst(y+x);
      }else if(op.equals("-")){
        int x=stack.removeFirst();
        int y=stack.removeFirst();
        stack.addFirst(y-x);
      }else if(op.equals("*")){
        int x=stack.removeFirst();
        int y=stack.removeFirst();
        stack.addFirst(y*x);
      }
    }

    System.out.println(stack.removeFirst());
  }
  static boolean isNum(String s){
    try{
      Integer.parseInt(s);
      return true;
    }catch(NumberFormatException e){
      return false;
    }
  }
} Main public static void main(String[] args)throws java.lang.NumberFormatException{
    Scanner scan=new Scanner(System.in);
    Deque<Integer> stack=new ArrayDeque<>();

    while(scan.hasNext()){
      String op=scan.next();
      if(isNum(op)){
        stack.addFirst(Integer.parseInt(op));
      }else if(op.equals("+")){
        int x=stack.removeFirst();
        int y=stack.removeFirst();
        stack.addFirst(y+x);
      }else if(op.equals("-")){
        int x=stack.removeFirst();
        int y=stack.removeFirst();
        stack.addFirst(y-x);
      }else if(op.equals("*")){
        int x=stack.removeFirst();
        int y=stack.removeFirst();
        stack.addFirst(y*x);
      }
    }

    System.out.println(stack.removeFirst());
  } main {
    Scanner scan=new Scanner(System.in);
    Deque<Integer> stack=new ArrayDeque<>();

    while(scan.hasNext()){
      String op=scan.next();
      if(isNum(op)){
        stack.addFirst(Integer.parseInt(op));
      }else if(op.equals("+")){
        int x=stack.removeFirst();
        int y=stack.removeFirst();
        stack.addFirst(y+x);
      }else if(op.equals("-")){
        int x=stack.removeFirst();
        int y=stack.removeFirst();
        stack.addFirst(y-x);
      }else if(op.equals("*")){
        int x=stack.removeFirst();
        int y=stack.removeFirst();
        stack.addFirst(y*x);
      }
    }

    System.out.println(stack.removeFirst());
  } Scanner scan=new Scanner(System.in); scan new Scanner(System.in) Deque<Integer> stack=new ArrayDeque<>(); stack new ArrayDeque<>() while(scan.hasNext()){
      String op=scan.next();
      if(isNum(op)){
        stack.addFirst(Integer.parseInt(op));
      }else if(op.equals("+")){
        int x=stack.removeFirst();
        int y=stack.removeFirst();
        stack.addFirst(y+x);
      }else if(op.equals("-")){
        int x=stack.removeFirst();
        int y=stack.removeFirst();
        stack.addFirst(y-x);
      }else if(op.equals("*")){
        int x=stack.removeFirst();
        int y=stack.removeFirst();
        stack.addFirst(y*x);
      }
    } scan.hasNext() scan.hasNext scan {
      String op=scan.next();
      if(isNum(op)){
        stack.addFirst(Integer.parseInt(op));
      }else if(op.equals("+")){
        int x=stack.removeFirst();
        int y=stack.removeFirst();
        stack.addFirst(y+x);
      }else if(op.equals("-")){
        int x=stack.removeFirst();
        int y=stack.removeFirst();
        stack.addFirst(y-x);
      }else if(op.equals("*")){
        int x=stack.removeFirst();
        int y=stack.removeFirst();
        stack.addFirst(y*x);
      }
    } String op=scan.next(); op scan.next() scan.next scan if(isNum(op)){
        stack.addFirst(Integer.parseInt(op));
      }else if(op.equals("+")){
        int x=stack.removeFirst();
        int y=stack.removeFirst();
        stack.addFirst(y+x);
      }else if(op.equals("-")){
        int x=stack.removeFirst();
        int y=stack.removeFirst();
        stack.addFirst(y-x);
      }else if(op.equals("*")){
        int x=stack.removeFirst();
        int y=stack.removeFirst();
        stack.addFirst(y*x);
      } isNum(op) isNum op {
        stack.addFirst(Integer.parseInt(op));
      } stack.addFirst(Integer.parseInt(op)) stack.addFirst stack Integer.parseInt(op) Integer.parseInt Integer op if(op.equals("+")){
        int x=stack.removeFirst();
        int y=stack.removeFirst();
        stack.addFirst(y+x);
      }else if(op.equals("-")){
        int x=stack.removeFirst();
        int y=stack.removeFirst();
        stack.addFirst(y-x);
      }else if(op.equals("*")){
        int x=stack.removeFirst();
        int y=stack.removeFirst();
        stack.addFirst(y*x);
      } op.equals("+") op.equals op "+" {
        int x=stack.removeFirst();
        int y=stack.removeFirst();
        stack.addFirst(y+x);
      } int x=stack.removeFirst(); x stack.removeFirst() stack.removeFirst stack int y=stack.removeFirst(); y stack.removeFirst() stack.removeFirst stack stack.addFirst(y+x) stack.addFirst stack y+x y x if(op.equals("-")){
        int x=stack.removeFirst();
        int y=stack.removeFirst();
        stack.addFirst(y-x);
      }else if(op.equals("*")){
        int x=stack.removeFirst();
        int y=stack.removeFirst();
        stack.addFirst(y*x);
      } op.equals("-") op.equals op "-" {
        int x=stack.removeFirst();
        int y=stack.removeFirst();
        stack.addFirst(y-x);
      } int x=stack.removeFirst(); x stack.removeFirst() stack.removeFirst stack int y=stack.removeFirst(); y stack.removeFirst() stack.removeFirst stack stack.addFirst(y-x) stack.addFirst stack y-x y x if(op.equals("*")){
        int x=stack.removeFirst();
        int y=stack.removeFirst();
        stack.addFirst(y*x);
      } op.equals("*") op.equals op "*" {
        int x=stack.removeFirst();
        int y=stack.removeFirst();
        stack.addFirst(y*x);
      } int x=stack.removeFirst(); x stack.removeFirst() stack.removeFirst stack int y=stack.removeFirst(); y stack.removeFirst() stack.removeFirst stack stack.addFirst(y*x) stack.addFirst stack y*x y x System.out.println(stack.removeFirst()) System.out.println System.out System System.out stack.removeFirst() stack.removeFirst stack String[] args args static boolean isNum(String s){
    try{
      Integer.parseInt(s);
      return true;
    }catch(NumberFormatException e){
      return false;
    }
  } isNum {
    try{
      Integer.parseInt(s);
      return true;
    }catch(NumberFormatException e){
      return false;
    }
  } try{
      Integer.parseInt(s);
      return true;
    }catch(NumberFormatException e){
      return false;
    } catch(NumberFormatException e){
      return false;
    } NumberFormatException e {
      return false;
    } return false; false {
      Integer.parseInt(s);
      return true;
    } Integer.parseInt(s) Integer.parseInt Integer s return true; true String s s
import java.io.*;
import java.util.*;

class Main{
  public static void main(String[] args)throws java.lang.NumberFormatException{
    Scanner scan=new Scanner(System.in);
    Deque<Integer> stack=new ArrayDeque<>();

    while(scan.hasNext()){
      String op=scan.next();
      if(isNum(op)){
        stack.addFirst(Integer.parseInt(op));
      }else if(op.equals("+")){
        int x=stack.removeFirst();
        int y=stack.removeFirst();
        stack.addFirst(y+x);
      }else if(op.equals("-")){
        int x=stack.removeFirst();
        int y=stack.removeFirst();
        stack.addFirst(y-x);
      }else if(op.equals("*")){
        int x=stack.removeFirst();
        int y=stack.removeFirst();
        stack.addFirst(y*x);
      }
    }

    System.out.println(stack.removeFirst());
  }
  static boolean isNum(String s){
    try{
      Integer.parseInt(s);
      return true;
    }catch(NumberFormatException e){
      return false;
    }
  }
}
