import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    Stack<String> stack = new Stack<String>();
    String s;
    
    while (in.hasNext()) {
      s = in.next();
      if (s.equals("+")) {
        int x = Integer.parseInt(stack.pop());
        int y = Integer.parseInt(stack.pop());
        stack.push(Integer.toString(y + x));
      }
      else if (s.equals("-")) {
        int x = Integer.parseInt(stack.pop());
        int y = Integer.parseInt(stack.pop());
        stack.push(Integer.toString(y - x));
      }
      else if (s.equals("*")) {
        int x = Integer.parseInt(stack.pop());
        int y = Integer.parseInt(stack.pop());
        stack.push(Integer.toString(y * x));
      }
      else {
        int num = Integer.parseInt(s);
        stack.push(Integer.toString(num));
      }
    }
    System.out.println(stack.pop());
  }
}

class Stack<Item> {
  private Node first = null;
  
  private class Node {
    Item item;
    Node next;
  }
  
  public boolean isEmpty() { return first == null; }
  
  public void push(Item item) {
    Node oldfirst = first;
    first = new Node();
    first.item = item;
    first.next = oldfirst;
  }
  
  public Item pop() {
    Item item = first.item;
    first = first.next;
    return item;
  }
} import java.util.Scanner; Scanner java.util class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    Stack<String> stack = new Stack<String>();
    String s;
    
    while (in.hasNext()) {
      s = in.next();
      if (s.equals("+")) {
        int x = Integer.parseInt(stack.pop());
        int y = Integer.parseInt(stack.pop());
        stack.push(Integer.toString(y + x));
      }
      else if (s.equals("-")) {
        int x = Integer.parseInt(stack.pop());
        int y = Integer.parseInt(stack.pop());
        stack.push(Integer.toString(y - x));
      }
      else if (s.equals("*")) {
        int x = Integer.parseInt(stack.pop());
        int y = Integer.parseInt(stack.pop());
        stack.push(Integer.toString(y * x));
      }
      else {
        int num = Integer.parseInt(s);
        stack.push(Integer.toString(num));
      }
    }
    System.out.println(stack.pop());
  }
} Main public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    Stack<String> stack = new Stack<String>();
    String s;
    
    while (in.hasNext()) {
      s = in.next();
      if (s.equals("+")) {
        int x = Integer.parseInt(stack.pop());
        int y = Integer.parseInt(stack.pop());
        stack.push(Integer.toString(y + x));
      }
      else if (s.equals("-")) {
        int x = Integer.parseInt(stack.pop());
        int y = Integer.parseInt(stack.pop());
        stack.push(Integer.toString(y - x));
      }
      else if (s.equals("*")) {
        int x = Integer.parseInt(stack.pop());
        int y = Integer.parseInt(stack.pop());
        stack.push(Integer.toString(y * x));
      }
      else {
        int num = Integer.parseInt(s);
        stack.push(Integer.toString(num));
      }
    }
    System.out.println(stack.pop());
  } main {
    Scanner in = new Scanner(System.in);
    Stack<String> stack = new Stack<String>();
    String s;
    
    while (in.hasNext()) {
      s = in.next();
      if (s.equals("+")) {
        int x = Integer.parseInt(stack.pop());
        int y = Integer.parseInt(stack.pop());
        stack.push(Integer.toString(y + x));
      }
      else if (s.equals("-")) {
        int x = Integer.parseInt(stack.pop());
        int y = Integer.parseInt(stack.pop());
        stack.push(Integer.toString(y - x));
      }
      else if (s.equals("*")) {
        int x = Integer.parseInt(stack.pop());
        int y = Integer.parseInt(stack.pop());
        stack.push(Integer.toString(y * x));
      }
      else {
        int num = Integer.parseInt(s);
        stack.push(Integer.toString(num));
      }
    }
    System.out.println(stack.pop());
  } Scanner in = new Scanner(System.in); in new Scanner(System.in) Stack<String> stack = new Stack<String>(); stack new Stack<String>() String s; s while (in.hasNext()) {
      s = in.next();
      if (s.equals("+")) {
        int x = Integer.parseInt(stack.pop());
        int y = Integer.parseInt(stack.pop());
        stack.push(Integer.toString(y + x));
      }
      else if (s.equals("-")) {
        int x = Integer.parseInt(stack.pop());
        int y = Integer.parseInt(stack.pop());
        stack.push(Integer.toString(y - x));
      }
      else if (s.equals("*")) {
        int x = Integer.parseInt(stack.pop());
        int y = Integer.parseInt(stack.pop());
        stack.push(Integer.toString(y * x));
      }
      else {
        int num = Integer.parseInt(s);
        stack.push(Integer.toString(num));
      }
    } in.hasNext() in.hasNext in {
      s = in.next();
      if (s.equals("+")) {
        int x = Integer.parseInt(stack.pop());
        int y = Integer.parseInt(stack.pop());
        stack.push(Integer.toString(y + x));
      }
      else if (s.equals("-")) {
        int x = Integer.parseInt(stack.pop());
        int y = Integer.parseInt(stack.pop());
        stack.push(Integer.toString(y - x));
      }
      else if (s.equals("*")) {
        int x = Integer.parseInt(stack.pop());
        int y = Integer.parseInt(stack.pop());
        stack.push(Integer.toString(y * x));
      }
      else {
        int num = Integer.parseInt(s);
        stack.push(Integer.toString(num));
      }
    } s = in.next() s in.next() in.next in if (s.equals("+")) {
        int x = Integer.parseInt(stack.pop());
        int y = Integer.parseInt(stack.pop());
        stack.push(Integer.toString(y + x));
      }
      else if (s.equals("-")) {
        int x = Integer.parseInt(stack.pop());
        int y = Integer.parseInt(stack.pop());
        stack.push(Integer.toString(y - x));
      }
      else if (s.equals("*")) {
        int x = Integer.parseInt(stack.pop());
        int y = Integer.parseInt(stack.pop());
        stack.push(Integer.toString(y * x));
      }
      else {
        int num = Integer.parseInt(s);
        stack.push(Integer.toString(num));
      } s.equals("+") s.equals s "+" {
        int x = Integer.parseInt(stack.pop());
        int y = Integer.parseInt(stack.pop());
        stack.push(Integer.toString(y + x));
      } int x = Integer.parseInt(stack.pop()); x Integer.parseInt(stack.pop()) Integer.parseInt Integer stack.pop() stack.pop stack int y = Integer.parseInt(stack.pop()); y Integer.parseInt(stack.pop()) Integer.parseInt Integer stack.pop() stack.pop stack stack.push(Integer.toString(y + x)) stack.push stack Integer.toString(y + x) Integer.toString Integer y + x y x if (s.equals("-")) {
        int x = Integer.parseInt(stack.pop());
        int y = Integer.parseInt(stack.pop());
        stack.push(Integer.toString(y - x));
      }
      else if (s.equals("*")) {
        int x = Integer.parseInt(stack.pop());
        int y = Integer.parseInt(stack.pop());
        stack.push(Integer.toString(y * x));
      }
      else {
        int num = Integer.parseInt(s);
        stack.push(Integer.toString(num));
      } s.equals("-") s.equals s "-" {
        int x = Integer.parseInt(stack.pop());
        int y = Integer.parseInt(stack.pop());
        stack.push(Integer.toString(y - x));
      } int x = Integer.parseInt(stack.pop()); x Integer.parseInt(stack.pop()) Integer.parseInt Integer stack.pop() stack.pop stack int y = Integer.parseInt(stack.pop()); y Integer.parseInt(stack.pop()) Integer.parseInt Integer stack.pop() stack.pop stack stack.push(Integer.toString(y - x)) stack.push stack Integer.toString(y - x) Integer.toString Integer y - x y x if (s.equals("*")) {
        int x = Integer.parseInt(stack.pop());
        int y = Integer.parseInt(stack.pop());
        stack.push(Integer.toString(y * x));
      }
      else {
        int num = Integer.parseInt(s);
        stack.push(Integer.toString(num));
      } s.equals("*") s.equals s "*" {
        int x = Integer.parseInt(stack.pop());
        int y = Integer.parseInt(stack.pop());
        stack.push(Integer.toString(y * x));
      } int x = Integer.parseInt(stack.pop()); x Integer.parseInt(stack.pop()) Integer.parseInt Integer stack.pop() stack.pop stack int y = Integer.parseInt(stack.pop()); y Integer.parseInt(stack.pop()) Integer.parseInt Integer stack.pop() stack.pop stack stack.push(Integer.toString(y * x)) stack.push stack Integer.toString(y * x) Integer.toString Integer y * x y x {
        int num = Integer.parseInt(s);
        stack.push(Integer.toString(num));
      } int num = Integer.parseInt(s); num Integer.parseInt(s) Integer.parseInt Integer s stack.push(Integer.toString(num)) stack.push stack Integer.toString(num) Integer.toString Integer num System.out.println(stack.pop()) System.out.println System.out System System.out stack.pop() stack.pop stack String[] args args class Stack<Item> {
  private Node first = null;
  
  private class Node {
    Item item;
    Node next;
  }
  
  public boolean isEmpty() { return first == null; }
  
  public void push(Item item) {
    Node oldfirst = first;
    first = new Node();
    first.item = item;
    first.next = oldfirst;
  }
  
  public Item pop() {
    Item item = first.item;
    first = first.next;
    return item;
  }
} Stack private Node first = null; first null public boolean isEmpty() { return first == null; } isEmpty { return first == null; } return first == null; first == null first null public void push(Item item) {
    Node oldfirst = first;
    first = new Node();
    first.item = item;
    first.next = oldfirst;
  } push {
    Node oldfirst = first;
    first = new Node();
    first.item = item;
    first.next = oldfirst;
  } Node oldfirst = first; oldfirst first first = new Node() first new Node() first.item = item first.item first first.item item first.next = oldfirst first.next first first.next oldfirst Item item item public Item pop() {
    Item item = first.item;
    first = first.next;
    return item;
  } pop {
    Item item = first.item;
    first = first.next;
    return item;
  } Item item = first.item; item first.item first first.item first = first.next first first.next first first.next return item; item private class Node {
    Item item;
    Node next;
  } Node Item item; item Node next; next
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    Stack<String> stack = new Stack<String>();
    String s;
    
    while (in.hasNext()) {
      s = in.next();
      if (s.equals("+")) {
        int x = Integer.parseInt(stack.pop());
        int y = Integer.parseInt(stack.pop());
        stack.push(Integer.toString(y + x));
      }
      else if (s.equals("-")) {
        int x = Integer.parseInt(stack.pop());
        int y = Integer.parseInt(stack.pop());
        stack.push(Integer.toString(y - x));
      }
      else if (s.equals("*")) {
        int x = Integer.parseInt(stack.pop());
        int y = Integer.parseInt(stack.pop());
        stack.push(Integer.toString(y * x));
      }
      else {
        int num = Integer.parseInt(s);
        stack.push(Integer.toString(num));
      }
    }
    System.out.println(stack.pop());
  }
}

class Stack<Item> {
  private Node first = null;
  
  private class Node {
    Item item;
    Node next;
  }
  
  public boolean isEmpty() { return first == null; }
  
  public void push(Item item) {
    Node oldfirst = first;
    first = new Node();
    first.item = item;
    first.next = oldfirst;
  }
  
  public Item pop() {
    Item item = first.item;
    first = first.next;
    return item;
  }
}