import java.util.*;

public class Main {
  public static boolean isNum(String str) {
    try {
      Integer.parseInt(str);
      return true;
    } catch(NumberFormatException e) {
      return false;
    }
  }

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    Deque<Integer> deq = new ArrayDeque<>();
    String s = "";
    int a = 0;
    while(sc.hasNext()) {
      s = sc.next();
      if(isNum(s)) {
        deq.addFirst(Integer.parseInt(s));
      } else if(s.equals("+")) {
        a = deq.pollFirst() + deq.pollFirst();
        deq.addFirst(a);
      } else if(s.equals("-")) {
        a = (deq.pollFirst() - deq.pollFirst()) * (-1);
        deq.addFirst(a);
      } else {
        a = deq.pollFirst() * deq.pollFirst();
        deq.addFirst(a);
      }
    }
    sc.close();
    System.out.println(deq.getFirst());
  }
}
 import java.util.*; util.* java public class Main {
  public static boolean isNum(String str) {
    try {
      Integer.parseInt(str);
      return true;
    } catch(NumberFormatException e) {
      return false;
    }
  }

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    Deque<Integer> deq = new ArrayDeque<>();
    String s = "";
    int a = 0;
    while(sc.hasNext()) {
      s = sc.next();
      if(isNum(s)) {
        deq.addFirst(Integer.parseInt(s));
      } else if(s.equals("+")) {
        a = deq.pollFirst() + deq.pollFirst();
        deq.addFirst(a);
      } else if(s.equals("-")) {
        a = (deq.pollFirst() - deq.pollFirst()) * (-1);
        deq.addFirst(a);
      } else {
        a = deq.pollFirst() * deq.pollFirst();
        deq.addFirst(a);
      }
    }
    sc.close();
    System.out.println(deq.getFirst());
  }
} Main public static boolean isNum(String str) {
    try {
      Integer.parseInt(str);
      return true;
    } catch(NumberFormatException e) {
      return false;
    }
  } isNum {
    try {
      Integer.parseInt(str);
      return true;
    } catch(NumberFormatException e) {
      return false;
    }
  } try {
      Integer.parseInt(str);
      return true;
    } catch(NumberFormatException e) {
      return false;
    } catch(NumberFormatException e) {
      return false;
    } NumberFormatException e {
      return false;
    } return false; false {
      Integer.parseInt(str);
      return true;
    } Integer.parseInt(str) Integer.parseInt Integer str return true; true String str str public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    Deque<Integer> deq = new ArrayDeque<>();
    String s = "";
    int a = 0;
    while(sc.hasNext()) {
      s = sc.next();
      if(isNum(s)) {
        deq.addFirst(Integer.parseInt(s));
      } else if(s.equals("+")) {
        a = deq.pollFirst() + deq.pollFirst();
        deq.addFirst(a);
      } else if(s.equals("-")) {
        a = (deq.pollFirst() - deq.pollFirst()) * (-1);
        deq.addFirst(a);
      } else {
        a = deq.pollFirst() * deq.pollFirst();
        deq.addFirst(a);
      }
    }
    sc.close();
    System.out.println(deq.getFirst());
  } main {
    Scanner sc = new Scanner(System.in);
    Deque<Integer> deq = new ArrayDeque<>();
    String s = "";
    int a = 0;
    while(sc.hasNext()) {
      s = sc.next();
      if(isNum(s)) {
        deq.addFirst(Integer.parseInt(s));
      } else if(s.equals("+")) {
        a = deq.pollFirst() + deq.pollFirst();
        deq.addFirst(a);
      } else if(s.equals("-")) {
        a = (deq.pollFirst() - deq.pollFirst()) * (-1);
        deq.addFirst(a);
      } else {
        a = deq.pollFirst() * deq.pollFirst();
        deq.addFirst(a);
      }
    }
    sc.close();
    System.out.println(deq.getFirst());
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) Deque<Integer> deq = new ArrayDeque<>(); deq new ArrayDeque<>() String s = ""; s "" int a = 0; a 0 while(sc.hasNext()) {
      s = sc.next();
      if(isNum(s)) {
        deq.addFirst(Integer.parseInt(s));
      } else if(s.equals("+")) {
        a = deq.pollFirst() + deq.pollFirst();
        deq.addFirst(a);
      } else if(s.equals("-")) {
        a = (deq.pollFirst() - deq.pollFirst()) * (-1);
        deq.addFirst(a);
      } else {
        a = deq.pollFirst() * deq.pollFirst();
        deq.addFirst(a);
      }
    } sc.hasNext() sc.hasNext sc {
      s = sc.next();
      if(isNum(s)) {
        deq.addFirst(Integer.parseInt(s));
      } else if(s.equals("+")) {
        a = deq.pollFirst() + deq.pollFirst();
        deq.addFirst(a);
      } else if(s.equals("-")) {
        a = (deq.pollFirst() - deq.pollFirst()) * (-1);
        deq.addFirst(a);
      } else {
        a = deq.pollFirst() * deq.pollFirst();
        deq.addFirst(a);
      }
    } s = sc.next() s sc.next() sc.next sc if(isNum(s)) {
        deq.addFirst(Integer.parseInt(s));
      } else if(s.equals("+")) {
        a = deq.pollFirst() + deq.pollFirst();
        deq.addFirst(a);
      } else if(s.equals("-")) {
        a = (deq.pollFirst() - deq.pollFirst()) * (-1);
        deq.addFirst(a);
      } else {
        a = deq.pollFirst() * deq.pollFirst();
        deq.addFirst(a);
      } isNum(s) isNum s {
        deq.addFirst(Integer.parseInt(s));
      } deq.addFirst(Integer.parseInt(s)) deq.addFirst deq Integer.parseInt(s) Integer.parseInt Integer s if(s.equals("+")) {
        a = deq.pollFirst() + deq.pollFirst();
        deq.addFirst(a);
      } else if(s.equals("-")) {
        a = (deq.pollFirst() - deq.pollFirst()) * (-1);
        deq.addFirst(a);
      } else {
        a = deq.pollFirst() * deq.pollFirst();
        deq.addFirst(a);
      } s.equals("+") s.equals s "+" {
        a = deq.pollFirst() + deq.pollFirst();
        deq.addFirst(a);
      } a = deq.pollFirst() + deq.pollFirst() a deq.pollFirst() + deq.pollFirst() deq.pollFirst() deq.pollFirst deq deq.pollFirst() deq.pollFirst deq deq.addFirst(a) deq.addFirst deq a if(s.equals("-")) {
        a = (deq.pollFirst() - deq.pollFirst()) * (-1);
        deq.addFirst(a);
      } else {
        a = deq.pollFirst() * deq.pollFirst();
        deq.addFirst(a);
      } s.equals("-") s.equals s "-" {
        a = (deq.pollFirst() - deq.pollFirst()) * (-1);
        deq.addFirst(a);
      } a = (deq.pollFirst() - deq.pollFirst()) * (-1) a (deq.pollFirst() - deq.pollFirst()) * (-1) (deq.pollFirst() - deq.pollFirst()) deq.pollFirst() deq.pollFirst deq deq.pollFirst() deq.pollFirst deq (-1) 1 deq.addFirst(a) deq.addFirst deq a {
        a = deq.pollFirst() * deq.pollFirst();
        deq.addFirst(a);
      } a = deq.pollFirst() * deq.pollFirst() a deq.pollFirst() * deq.pollFirst() deq.pollFirst() deq.pollFirst deq deq.pollFirst() deq.pollFirst deq deq.addFirst(a) deq.addFirst deq a sc.close() sc.close sc System.out.println(deq.getFirst()) System.out.println System.out System System.out deq.getFirst() deq.getFirst deq String[] args args public class Main {
  public static boolean isNum(String str) {
    try {
      Integer.parseInt(str);
      return true;
    } catch(NumberFormatException e) {
      return false;
    }
  }

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    Deque<Integer> deq = new ArrayDeque<>();
    String s = "";
    int a = 0;
    while(sc.hasNext()) {
      s = sc.next();
      if(isNum(s)) {
        deq.addFirst(Integer.parseInt(s));
      } else if(s.equals("+")) {
        a = deq.pollFirst() + deq.pollFirst();
        deq.addFirst(a);
      } else if(s.equals("-")) {
        a = (deq.pollFirst() - deq.pollFirst()) * (-1);
        deq.addFirst(a);
      } else {
        a = deq.pollFirst() * deq.pollFirst();
        deq.addFirst(a);
      }
    }
    sc.close();
    System.out.println(deq.getFirst());
  }
} public class Main {
  public static boolean isNum(String str) {
    try {
      Integer.parseInt(str);
      return true;
    } catch(NumberFormatException e) {
      return false;
    }
  }

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    Deque<Integer> deq = new ArrayDeque<>();
    String s = "";
    int a = 0;
    while(sc.hasNext()) {
      s = sc.next();
      if(isNum(s)) {
        deq.addFirst(Integer.parseInt(s));
      } else if(s.equals("+")) {
        a = deq.pollFirst() + deq.pollFirst();
        deq.addFirst(a);
      } else if(s.equals("-")) {
        a = (deq.pollFirst() - deq.pollFirst()) * (-1);
        deq.addFirst(a);
      } else {
        a = deq.pollFirst() * deq.pollFirst();
        deq.addFirst(a);
      }
    }
    sc.close();
    System.out.println(deq.getFirst());
  }
} Main
import java.util.*;

public class Main {
  public static boolean isNum(String str) {
    try {
      Integer.parseInt(str);
      return true;
    } catch(NumberFormatException e) {
      return false;
    }
  }

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    Deque<Integer> deq = new ArrayDeque<>();
    String s = "";
    int a = 0;
    while(sc.hasNext()) {
      s = sc.next();
      if(isNum(s)) {
        deq.addFirst(Integer.parseInt(s));
      } else if(s.equals("+")) {
        a = deq.pollFirst() + deq.pollFirst();
        deq.addFirst(a);
      } else if(s.equals("-")) {
        a = (deq.pollFirst() - deq.pollFirst()) * (-1);
        deq.addFirst(a);
      } else {
        a = deq.pollFirst() * deq.pollFirst();
        deq.addFirst(a);
      }
    }
    sc.close();
    System.out.println(deq.getFirst());
  }
}

