import java.util.*;

public class Main {
  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      Deque<Integer> stack = new ArrayDeque<>();
      int tmpA = 0, tmpB = 0;
      String[] str = sc.nextLine().split("\\s");

      for (String s : str) {
        if (s.equals("+")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpA + tmpB);
        } else if (s.equals("-")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpB - tmpA);
        } else if (s.equals("*")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpA * tmpB);
        } else {
          stack.push(Integer.valueOf(s));
        }
      }

      System.out.println(stack.pop());
    }
  }
}
 import java.util.*; util.* java public class Main {
  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      Deque<Integer> stack = new ArrayDeque<>();
      int tmpA = 0, tmpB = 0;
      String[] str = sc.nextLine().split("\\s");

      for (String s : str) {
        if (s.equals("+")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpA + tmpB);
        } else if (s.equals("-")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpB - tmpA);
        } else if (s.equals("*")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpA * tmpB);
        } else {
          stack.push(Integer.valueOf(s));
        }
      }

      System.out.println(stack.pop());
    }
  }
} Main public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      Deque<Integer> stack = new ArrayDeque<>();
      int tmpA = 0, tmpB = 0;
      String[] str = sc.nextLine().split("\\s");

      for (String s : str) {
        if (s.equals("+")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpA + tmpB);
        } else if (s.equals("-")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpB - tmpA);
        } else if (s.equals("*")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpA * tmpB);
        } else {
          stack.push(Integer.valueOf(s));
        }
      }

      System.out.println(stack.pop());
    }
  } main {
    try (Scanner sc = new Scanner(System.in)) {
      Deque<Integer> stack = new ArrayDeque<>();
      int tmpA = 0, tmpB = 0;
      String[] str = sc.nextLine().split("\\s");

      for (String s : str) {
        if (s.equals("+")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpA + tmpB);
        } else if (s.equals("-")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpB - tmpA);
        } else if (s.equals("*")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpA * tmpB);
        } else {
          stack.push(Integer.valueOf(s));
        }
      }

      System.out.println(stack.pop());
    }
  } try (Scanner sc = new Scanner(System.in)) {
      Deque<Integer> stack = new ArrayDeque<>();
      int tmpA = 0, tmpB = 0;
      String[] str = sc.nextLine().split("\\s");

      for (String s : str) {
        if (s.equals("+")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpA + tmpB);
        } else if (s.equals("-")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpB - tmpA);
        } else if (s.equals("*")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpA * tmpB);
        } else {
          stack.push(Integer.valueOf(s));
        }
      }

      System.out.println(stack.pop());
    } {
      Deque<Integer> stack = new ArrayDeque<>();
      int tmpA = 0, tmpB = 0;
      String[] str = sc.nextLine().split("\\s");

      for (String s : str) {
        if (s.equals("+")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpA + tmpB);
        } else if (s.equals("-")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpB - tmpA);
        } else if (s.equals("*")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpA * tmpB);
        } else {
          stack.push(Integer.valueOf(s));
        }
      }

      System.out.println(stack.pop());
    } Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) Deque<Integer> stack = new ArrayDeque<>(); stack new ArrayDeque<>() int tmpA = 0 tmpA 0 tmpB = 0; tmpB 0 String[] str = sc.nextLine().split("\\s"); str sc.nextLine().split("\\s") sc.nextLine().split sc.nextLine() sc.nextLine sc "\\s" for (String s : str) {
        if (s.equals("+")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpA + tmpB);
        } else if (s.equals("-")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpB - tmpA);
        } else if (s.equals("*")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpA * tmpB);
        } else {
          stack.push(Integer.valueOf(s));
        }
      } String s str {
        if (s.equals("+")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpA + tmpB);
        } else if (s.equals("-")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpB - tmpA);
        } else if (s.equals("*")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpA * tmpB);
        } else {
          stack.push(Integer.valueOf(s));
        }
      } {
        if (s.equals("+")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpA + tmpB);
        } else if (s.equals("-")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpB - tmpA);
        } else if (s.equals("*")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpA * tmpB);
        } else {
          stack.push(Integer.valueOf(s));
        }
      } if (s.equals("+")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpA + tmpB);
        } else if (s.equals("-")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpB - tmpA);
        } else if (s.equals("*")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpA * tmpB);
        } else {
          stack.push(Integer.valueOf(s));
        } s.equals("+") s.equals s "+" {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpA + tmpB);
        } tmpA = stack.pop() tmpA stack.pop() stack.pop stack tmpB = stack.pop() tmpB stack.pop() stack.pop stack stack.push(tmpA + tmpB) stack.push stack tmpA + tmpB tmpA tmpB if (s.equals("-")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpB - tmpA);
        } else if (s.equals("*")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpA * tmpB);
        } else {
          stack.push(Integer.valueOf(s));
        } s.equals("-") s.equals s "-" {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpB - tmpA);
        } tmpA = stack.pop() tmpA stack.pop() stack.pop stack tmpB = stack.pop() tmpB stack.pop() stack.pop stack stack.push(tmpB - tmpA) stack.push stack tmpB - tmpA tmpB tmpA if (s.equals("*")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpA * tmpB);
        } else {
          stack.push(Integer.valueOf(s));
        } s.equals("*") s.equals s "*" {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpA * tmpB);
        } tmpA = stack.pop() tmpA stack.pop() stack.pop stack tmpB = stack.pop() tmpB stack.pop() stack.pop stack stack.push(tmpA * tmpB) stack.push stack tmpA * tmpB tmpA tmpB {
          stack.push(Integer.valueOf(s));
        } stack.push(Integer.valueOf(s)) stack.push stack Integer.valueOf(s) Integer.valueOf Integer s 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) {
    try (Scanner sc = new Scanner(System.in)) {
      Deque<Integer> stack = new ArrayDeque<>();
      int tmpA = 0, tmpB = 0;
      String[] str = sc.nextLine().split("\\s");

      for (String s : str) {
        if (s.equals("+")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpA + tmpB);
        } else if (s.equals("-")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpB - tmpA);
        } else if (s.equals("*")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpA * tmpB);
        } else {
          stack.push(Integer.valueOf(s));
        }
      }

      System.out.println(stack.pop());
    }
  }
} public class Main {
  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      Deque<Integer> stack = new ArrayDeque<>();
      int tmpA = 0, tmpB = 0;
      String[] str = sc.nextLine().split("\\s");

      for (String s : str) {
        if (s.equals("+")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpA + tmpB);
        } else if (s.equals("-")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpB - tmpA);
        } else if (s.equals("*")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpA * tmpB);
        } else {
          stack.push(Integer.valueOf(s));
        }
      }

      System.out.println(stack.pop());
    }
  }
} Main
import java.util.*;

public class Main {
  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      Deque<Integer> stack = new ArrayDeque<>();
      int tmpA = 0, tmpB = 0;
      String[] str = sc.nextLine().split("\\s");

      for (String s : str) {
        if (s.equals("+")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpA + tmpB);
        } else if (s.equals("-")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpB - tmpA);
        } else if (s.equals("*")) {
          tmpA = stack.pop();
          tmpB = stack.pop();
          stack.push(tmpA * tmpB);
        } else {
          stack.push(Integer.valueOf(s));
        }
      }

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

