#include<stdio.h>
#define size 100
#define length 1000

int A[size];
int stacksize=0;

int main()
{
        char B[length];

        scanf("%[^\n]*s", B);
        printf("%d\n",calc());
        return 0;
}


int pop(){
  if(stacksize <= 0)
  return 0;
  return A[--stacksize];
}

int push(){
  int a;
  A[stacksize++]=a;
}

int d(){
  char *w;
  if(*w == '+' || *w == '-'){
    w++;
    if(*w >= '0' && *w <= '9')
    return 1;
    return 0;
  }
  if (*w >= '0' && *w <= '9') return 1;
       return 0;
}

int number(){
  char *w;
  int s=0,n=0;
  if(*w == '+'){
    w++;
  } else if (*w == '-') {
                s = 1;
                w++;
        }
        while (*w >= '0' && *w <= '9') {
                n = n * 10 + (*w - '0');
                w++;
        }
        if (s) return -n;
        return n;
}

int calc(){
  char *w;
  int l, m, n;
  while (*w) {
    if (d(w)) {
        n = number(w);
        push(n);
  while (*w == '-' || *w == '+') {
        w++;
}
  while (n) {
    n /= 10;
    w++;
  }
} else {
  switch (*w) {
    case '+': l = pop();
              m = pop();
    push(m+l);
    break;
    case '-': l = pop();
              m = pop();
    push(m-l);
    break;
    case '*': l = pop();
              m = pop();
    push(m*l);
    break;
    case '/': l = pop();
              m = pop();
    if (l == 0) break;
    push(m/l);
    break;
    case '%': l = pop();
              m = pop();
    if (l == 0) break;
    push(m%l);
  }
    w++;
  }
}
  return pop();
}

