import java.util.Scanner;
import java.util.Stack;

public class Main {

  char[] c;
  int id;

  int number() {
    int ret = 0;
    while (id < c.length && c[id] != ' ') {
      ret *= 10;
      ret += c[id] - '0';
      id++;
    }
    id++;
    return ret;
  }

  int operand() {
    int ret = c[id];
    id += 2;
    return ret;
  }

  int calc(int s, int t, int op) {
    if (op == '+') {
      return s + t;
    }
    if (op == '-') {
      return s - t;
    }
    if (op == '*') {
      return s * t;
    }
    return 999;
  }

  void run() {
    Scanner sc = new Scanner(System.in);

    c = sc.nextLine().toCharArray();
    id = 0;

    Stack<Integer> stack = new Stack<Integer>();
    while (id < c.length) {
      if ('0' <= c[id] && c[id] <= '9') {
        int k = number();
        stack.push(k);
      } else {
        int op = operand();
        int s = stack.pop();
        int t = stack.pop();
        int u = calc(t, s, op);
        stack.push(u);
      }
    }
    System.out.println(stack.peek());
  }

  public static void main(String[] args) {
    new Main().run();
  }
} import java.util.Scanner; Scanner java.util import java.util.Stack; Stack java.util public class Main {

  char[] c;
  int id;

  int number() {
    int ret = 0;
    while (id < c.length && c[id] != ' ') {
      ret *= 10;
      ret += c[id] - '0';
      id++;
    }
    id++;
    return ret;
  }

  int operand() {
    int ret = c[id];
    id += 2;
    return ret;
  }

  int calc(int s, int t, int op) {
    if (op == '+') {
      return s + t;
    }
    if (op == '-') {
      return s - t;
    }
    if (op == '*') {
      return s * t;
    }
    return 999;
  }

  void run() {
    Scanner sc = new Scanner(System.in);

    c = sc.nextLine().toCharArray();
    id = 0;

    Stack<Integer> stack = new Stack<Integer>();
    while (id < c.length) {
      if ('0' <= c[id] && c[id] <= '9') {
        int k = number();
        stack.push(k);
      } else {
        int op = operand();
        int s = stack.pop();
        int t = stack.pop();
        int u = calc(t, s, op);
        stack.push(u);
      }
    }
    System.out.println(stack.peek());
  }

  public static void main(String[] args) {
    new Main().run();
  }
} Main char[] c; c int id; id int number() {
    int ret = 0;
    while (id < c.length && c[id] != ' ') {
      ret *= 10;
      ret += c[id] - '0';
      id++;
    }
    id++;
    return ret;
  } number {
    int ret = 0;
    while (id < c.length && c[id] != ' ') {
      ret *= 10;
      ret += c[id] - '0';
      id++;
    }
    id++;
    return ret;
  } int ret = 0; ret 0 while (id < c.length && c[id] != ' ') {
      ret *= 10;
      ret += c[id] - '0';
      id++;
    } id < c.length && c[id] != ' ' id < c.length id c.length c c.length c[id] != ' ' c[id] c id ' ' {
      ret *= 10;
      ret += c[id] - '0';
      id++;
    } ret *= 10 ret 10 ret += c[id] - '0' ret c[id] - '0' c[id] c id '0' id++ id id++ id return ret; ret int operand() {
    int ret = c[id];
    id += 2;
    return ret;
  } operand {
    int ret = c[id];
    id += 2;
    return ret;
  } int ret = c[id]; ret c[id] c id id += 2 id 2 return ret; ret int calc(int s, int t, int op) {
    if (op == '+') {
      return s + t;
    }
    if (op == '-') {
      return s - t;
    }
    if (op == '*') {
      return s * t;
    }
    return 999;
  } calc {
    if (op == '+') {
      return s + t;
    }
    if (op == '-') {
      return s - t;
    }
    if (op == '*') {
      return s * t;
    }
    return 999;
  } if (op == '+') {
      return s + t;
    } op == '+' op '+' {
      return s + t;
    } return s + t; s + t s t if (op == '-') {
      return s - t;
    } op == '-' op '-' {
      return s - t;
    } return s - t; s - t s t if (op == '*') {
      return s * t;
    } op == '*' op '*' {
      return s * t;
    } return s * t; s * t s t return 999; 999 int s s int t t int op op void run() {
    Scanner sc = new Scanner(System.in);

    c = sc.nextLine().toCharArray();
    id = 0;

    Stack<Integer> stack = new Stack<Integer>();
    while (id < c.length) {
      if ('0' <= c[id] && c[id] <= '9') {
        int k = number();
        stack.push(k);
      } else {
        int op = operand();
        int s = stack.pop();
        int t = stack.pop();
        int u = calc(t, s, op);
        stack.push(u);
      }
    }
    System.out.println(stack.peek());
  } run {
    Scanner sc = new Scanner(System.in);

    c = sc.nextLine().toCharArray();
    id = 0;

    Stack<Integer> stack = new Stack<Integer>();
    while (id < c.length) {
      if ('0' <= c[id] && c[id] <= '9') {
        int k = number();
        stack.push(k);
      } else {
        int op = operand();
        int s = stack.pop();
        int t = stack.pop();
        int u = calc(t, s, op);
        stack.push(u);
      }
    }
    System.out.println(stack.peek());
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) c = sc.nextLine().toCharArray() c sc.nextLine().toCharArray() sc.nextLine().toCharArray sc.nextLine() sc.nextLine sc id = 0 id 0 Stack<Integer> stack = new Stack<Integer>(); stack new Stack<Integer>() while (id < c.length) {
      if ('0' <= c[id] && c[id] <= '9') {
        int k = number();
        stack.push(k);
      } else {
        int op = operand();
        int s = stack.pop();
        int t = stack.pop();
        int u = calc(t, s, op);
        stack.push(u);
      }
    } id < c.length id c.length c c.length {
      if ('0' <= c[id] && c[id] <= '9') {
        int k = number();
        stack.push(k);
      } else {
        int op = operand();
        int s = stack.pop();
        int t = stack.pop();
        int u = calc(t, s, op);
        stack.push(u);
      }
    } if ('0' <= c[id] && c[id] <= '9') {
        int k = number();
        stack.push(k);
      } else {
        int op = operand();
        int s = stack.pop();
        int t = stack.pop();
        int u = calc(t, s, op);
        stack.push(u);
      } '0' <= c[id] && c[id] <= '9' '0' <= c[id] '0' c[id] c id c[id] <= '9' c[id] c id '9' {
        int k = number();
        stack.push(k);
      } int k = number(); k number() number stack.push(k) stack.push stack k {
        int op = operand();
        int s = stack.pop();
        int t = stack.pop();
        int u = calc(t, s, op);
        stack.push(u);
      } int op = operand(); op operand() operand int s = stack.pop(); s stack.pop() stack.pop stack int t = stack.pop(); t stack.pop() stack.pop stack int u = calc(t, s, op); u calc(t, s, op) calc t s op stack.push(u) stack.push stack u System.out.println(stack.peek()) System.out.println System.out System System.out stack.peek() stack.peek stack public static void main(String[] args) {
    new Main().run();
  } main {
    new Main().run();
  } new Main().run() new Main().run new Main() String[] args args public class Main {

  char[] c;
  int id;

  int number() {
    int ret = 0;
    while (id < c.length && c[id] != ' ') {
      ret *= 10;
      ret += c[id] - '0';
      id++;
    }
    id++;
    return ret;
  }

  int operand() {
    int ret = c[id];
    id += 2;
    return ret;
  }

  int calc(int s, int t, int op) {
    if (op == '+') {
      return s + t;
    }
    if (op == '-') {
      return s - t;
    }
    if (op == '*') {
      return s * t;
    }
    return 999;
  }

  void run() {
    Scanner sc = new Scanner(System.in);

    c = sc.nextLine().toCharArray();
    id = 0;

    Stack<Integer> stack = new Stack<Integer>();
    while (id < c.length) {
      if ('0' <= c[id] && c[id] <= '9') {
        int k = number();
        stack.push(k);
      } else {
        int op = operand();
        int s = stack.pop();
        int t = stack.pop();
        int u = calc(t, s, op);
        stack.push(u);
      }
    }
    System.out.println(stack.peek());
  }

  public static void main(String[] args) {
    new Main().run();
  }
} public class Main {

  char[] c;
  int id;

  int number() {
    int ret = 0;
    while (id < c.length && c[id] != ' ') {
      ret *= 10;
      ret += c[id] - '0';
      id++;
    }
    id++;
    return ret;
  }

  int operand() {
    int ret = c[id];
    id += 2;
    return ret;
  }

  int calc(int s, int t, int op) {
    if (op == '+') {
      return s + t;
    }
    if (op == '-') {
      return s - t;
    }
    if (op == '*') {
      return s * t;
    }
    return 999;
  }

  void run() {
    Scanner sc = new Scanner(System.in);

    c = sc.nextLine().toCharArray();
    id = 0;

    Stack<Integer> stack = new Stack<Integer>();
    while (id < c.length) {
      if ('0' <= c[id] && c[id] <= '9') {
        int k = number();
        stack.push(k);
      } else {
        int op = operand();
        int s = stack.pop();
        int t = stack.pop();
        int u = calc(t, s, op);
        stack.push(u);
      }
    }
    System.out.println(stack.peek());
  }

  public static void main(String[] args) {
    new Main().run();
  }
} Main
import java.util.Scanner;
import java.util.Stack;

public class Main {

  char[] c;
  int id;

  int number() {
    int ret = 0;
    while (id < c.length && c[id] != ' ') {
      ret *= 10;
      ret += c[id] - '0';
      id++;
    }
    id++;
    return ret;
  }

  int operand() {
    int ret = c[id];
    id += 2;
    return ret;
  }

  int calc(int s, int t, int op) {
    if (op == '+') {
      return s + t;
    }
    if (op == '-') {
      return s - t;
    }
    if (op == '*') {
      return s * t;
    }
    return 999;
  }

  void run() {
    Scanner sc = new Scanner(System.in);

    c = sc.nextLine().toCharArray();
    id = 0;

    Stack<Integer> stack = new Stack<Integer>();
    while (id < c.length) {
      if ('0' <= c[id] && c[id] <= '9') {
        int k = number();
        stack.push(k);
      } else {
        int op = operand();
        int s = stack.pop();
        int t = stack.pop();
        int u = calc(t, s, op);
        stack.push(u);
      }
    }
    System.out.println(stack.peek());
  }

  public static void main(String[] args) {
    new Main().run();
  }
}