import java.util.*;

public class Main {
  public static boolean isNum(String s) {
    try {
      int n = Integer.parseInt(s);
      return true;
    } catch(NumberFormatException e) {
      return false;
    }
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    List<Long> stack = new ArrayList<>();
    while(sc.hasNext()) {
      String s = sc.next();
      if(isNum(s)) {
        stack.add(Long.parseLong(s));
      } else {
        if(s.equals("+")) {
          long a = stack.get(stack.size() - 2) + stack.get(stack.size() - 1);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        } else if(s.equals("-")) {
          long a = stack.get(stack.size() - 2) - stack.get(stack.size() - 1);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        } else {
          long a = stack.get(stack.size() - 1) * stack.get(stack.size() - 2);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        }
      }
    }
    System.out.println(stack.get(0));
  }
}
 import java.util.*; util.* java public class Main {
  public static boolean isNum(String s) {
    try {
      int n = Integer.parseInt(s);
      return true;
    } catch(NumberFormatException e) {
      return false;
    }
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    List<Long> stack = new ArrayList<>();
    while(sc.hasNext()) {
      String s = sc.next();
      if(isNum(s)) {
        stack.add(Long.parseLong(s));
      } else {
        if(s.equals("+")) {
          long a = stack.get(stack.size() - 2) + stack.get(stack.size() - 1);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        } else if(s.equals("-")) {
          long a = stack.get(stack.size() - 2) - stack.get(stack.size() - 1);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        } else {
          long a = stack.get(stack.size() - 1) * stack.get(stack.size() - 2);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        }
      }
    }
    System.out.println(stack.get(0));
  }
} Main public static boolean isNum(String s) {
    try {
      int n = Integer.parseInt(s);
      return true;
    } catch(NumberFormatException e) {
      return false;
    }
  } isNum {
    try {
      int n = Integer.parseInt(s);
      return true;
    } catch(NumberFormatException e) {
      return false;
    }
  } try {
      int n = Integer.parseInt(s);
      return true;
    } catch(NumberFormatException e) {
      return false;
    } catch(NumberFormatException e) {
      return false;
    } NumberFormatException e {
      return false;
    } return false; false {
      int n = Integer.parseInt(s);
      return true;
    } int n = Integer.parseInt(s); n Integer.parseInt(s) Integer.parseInt Integer s return true; true String s s public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    List<Long> stack = new ArrayList<>();
    while(sc.hasNext()) {
      String s = sc.next();
      if(isNum(s)) {
        stack.add(Long.parseLong(s));
      } else {
        if(s.equals("+")) {
          long a = stack.get(stack.size() - 2) + stack.get(stack.size() - 1);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        } else if(s.equals("-")) {
          long a = stack.get(stack.size() - 2) - stack.get(stack.size() - 1);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        } else {
          long a = stack.get(stack.size() - 1) * stack.get(stack.size() - 2);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        }
      }
    }
    System.out.println(stack.get(0));
  } main {
    Scanner sc = new Scanner(System.in);
    List<Long> stack = new ArrayList<>();
    while(sc.hasNext()) {
      String s = sc.next();
      if(isNum(s)) {
        stack.add(Long.parseLong(s));
      } else {
        if(s.equals("+")) {
          long a = stack.get(stack.size() - 2) + stack.get(stack.size() - 1);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        } else if(s.equals("-")) {
          long a = stack.get(stack.size() - 2) - stack.get(stack.size() - 1);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        } else {
          long a = stack.get(stack.size() - 1) * stack.get(stack.size() - 2);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        }
      }
    }
    System.out.println(stack.get(0));
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) List<Long> stack = new ArrayList<>(); stack new ArrayList<>() while(sc.hasNext()) {
      String s = sc.next();
      if(isNum(s)) {
        stack.add(Long.parseLong(s));
      } else {
        if(s.equals("+")) {
          long a = stack.get(stack.size() - 2) + stack.get(stack.size() - 1);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        } else if(s.equals("-")) {
          long a = stack.get(stack.size() - 2) - stack.get(stack.size() - 1);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        } else {
          long a = stack.get(stack.size() - 1) * stack.get(stack.size() - 2);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        }
      }
    } sc.hasNext() sc.hasNext sc {
      String s = sc.next();
      if(isNum(s)) {
        stack.add(Long.parseLong(s));
      } else {
        if(s.equals("+")) {
          long a = stack.get(stack.size() - 2) + stack.get(stack.size() - 1);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        } else if(s.equals("-")) {
          long a = stack.get(stack.size() - 2) - stack.get(stack.size() - 1);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        } else {
          long a = stack.get(stack.size() - 1) * stack.get(stack.size() - 2);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        }
      }
    } String s = sc.next(); s sc.next() sc.next sc if(isNum(s)) {
        stack.add(Long.parseLong(s));
      } else {
        if(s.equals("+")) {
          long a = stack.get(stack.size() - 2) + stack.get(stack.size() - 1);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        } else if(s.equals("-")) {
          long a = stack.get(stack.size() - 2) - stack.get(stack.size() - 1);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        } else {
          long a = stack.get(stack.size() - 1) * stack.get(stack.size() - 2);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        }
      } isNum(s) isNum s {
        stack.add(Long.parseLong(s));
      } stack.add(Long.parseLong(s)) stack.add stack Long.parseLong(s) Long.parseLong Long s {
        if(s.equals("+")) {
          long a = stack.get(stack.size() - 2) + stack.get(stack.size() - 1);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        } else if(s.equals("-")) {
          long a = stack.get(stack.size() - 2) - stack.get(stack.size() - 1);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        } else {
          long a = stack.get(stack.size() - 1) * stack.get(stack.size() - 2);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        }
      } if(s.equals("+")) {
          long a = stack.get(stack.size() - 2) + stack.get(stack.size() - 1);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        } else if(s.equals("-")) {
          long a = stack.get(stack.size() - 2) - stack.get(stack.size() - 1);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        } else {
          long a = stack.get(stack.size() - 1) * stack.get(stack.size() - 2);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        } s.equals("+") s.equals s "+" {
          long a = stack.get(stack.size() - 2) + stack.get(stack.size() - 1);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        } long a = stack.get(stack.size() - 2) + stack.get(stack.size() - 1); a stack.get(stack.size() - 2) + stack.get(stack.size() - 1) stack.get(stack.size() - 2) stack.get stack stack.size() - 2 stack.size() stack.size stack 2 stack.get(stack.size() - 1) stack.get stack stack.size() - 1 stack.size() stack.size stack 1 stack.remove(stack.size() - 1) stack.remove stack stack.size() - 1 stack.size() stack.size stack 1 stack.set(stack.size() - 1, a) stack.set stack stack.size() - 1 stack.size() stack.size stack 1 a if(s.equals("-")) {
          long a = stack.get(stack.size() - 2) - stack.get(stack.size() - 1);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        } else {
          long a = stack.get(stack.size() - 1) * stack.get(stack.size() - 2);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        } s.equals("-") s.equals s "-" {
          long a = stack.get(stack.size() - 2) - stack.get(stack.size() - 1);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        } long a = stack.get(stack.size() - 2) - stack.get(stack.size() - 1); a stack.get(stack.size() - 2) - stack.get(stack.size() - 1) stack.get(stack.size() - 2) stack.get stack stack.size() - 2 stack.size() stack.size stack 2 stack.get(stack.size() - 1) stack.get stack stack.size() - 1 stack.size() stack.size stack 1 stack.remove(stack.size() - 1) stack.remove stack stack.size() - 1 stack.size() stack.size stack 1 stack.set(stack.size() - 1, a) stack.set stack stack.size() - 1 stack.size() stack.size stack 1 a {
          long a = stack.get(stack.size() - 1) * stack.get(stack.size() - 2);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        } long a = stack.get(stack.size() - 1) * stack.get(stack.size() - 2); a stack.get(stack.size() - 1) * stack.get(stack.size() - 2) stack.get(stack.size() - 1) stack.get stack stack.size() - 1 stack.size() stack.size stack 1 stack.get(stack.size() - 2) stack.get stack stack.size() - 2 stack.size() stack.size stack 2 stack.remove(stack.size() - 1) stack.remove stack stack.size() - 1 stack.size() stack.size stack 1 stack.set(stack.size() - 1, a) stack.set stack stack.size() - 1 stack.size() stack.size stack 1 a System.out.println(stack.get(0)) System.out.println System.out System System.out stack.get(0) stack.get stack 0 String[] args args public class Main {
  public static boolean isNum(String s) {
    try {
      int n = Integer.parseInt(s);
      return true;
    } catch(NumberFormatException e) {
      return false;
    }
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    List<Long> stack = new ArrayList<>();
    while(sc.hasNext()) {
      String s = sc.next();
      if(isNum(s)) {
        stack.add(Long.parseLong(s));
      } else {
        if(s.equals("+")) {
          long a = stack.get(stack.size() - 2) + stack.get(stack.size() - 1);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        } else if(s.equals("-")) {
          long a = stack.get(stack.size() - 2) - stack.get(stack.size() - 1);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        } else {
          long a = stack.get(stack.size() - 1) * stack.get(stack.size() - 2);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        }
      }
    }
    System.out.println(stack.get(0));
  }
} public class Main {
  public static boolean isNum(String s) {
    try {
      int n = Integer.parseInt(s);
      return true;
    } catch(NumberFormatException e) {
      return false;
    }
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    List<Long> stack = new ArrayList<>();
    while(sc.hasNext()) {
      String s = sc.next();
      if(isNum(s)) {
        stack.add(Long.parseLong(s));
      } else {
        if(s.equals("+")) {
          long a = stack.get(stack.size() - 2) + stack.get(stack.size() - 1);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        } else if(s.equals("-")) {
          long a = stack.get(stack.size() - 2) - stack.get(stack.size() - 1);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        } else {
          long a = stack.get(stack.size() - 1) * stack.get(stack.size() - 2);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        }
      }
    }
    System.out.println(stack.get(0));
  }
} Main
import java.util.*;

public class Main {
  public static boolean isNum(String s) {
    try {
      int n = Integer.parseInt(s);
      return true;
    } catch(NumberFormatException e) {
      return false;
    }
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    List<Long> stack = new ArrayList<>();
    while(sc.hasNext()) {
      String s = sc.next();
      if(isNum(s)) {
        stack.add(Long.parseLong(s));
      } else {
        if(s.equals("+")) {
          long a = stack.get(stack.size() - 2) + stack.get(stack.size() - 1);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        } else if(s.equals("-")) {
          long a = stack.get(stack.size() - 2) - stack.get(stack.size() - 1);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        } else {
          long a = stack.get(stack.size() - 1) * stack.get(stack.size() - 2);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        }
      }
    }
    System.out.println(stack.get(0));
  }
}

