#include<stdio.h>
#include<stdlib.h>
#define N 100

void push(int);
int pop(void);
int stack[N];
int top = 0;

int main(){
    int a,b,num = 0;
    char c[N];
    
    while(scanf("%s",c) != -1){
        if(c[0] == '+'){
         a = pop();
         b = pop();
        num = a + b;
        push(num);
      }else if(c[0] == '-'){
          a = pop();
          b = pop();
          num = b - a;
          push(num);
      }else if(c[0] == '*'){
          a = pop();
          b = pop();
          num = a * b;
          push(num);
      }else push(atoi(c));
    }
    printf("%d\n",pop());
    return 0;
}
void push(int a)
{
    top++;
    stack[top] = a;
}
int pop(void){
    top--;
    return stack[top+1];
}
