#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void push(int);
int pop();

int top,stack[200];

int main(){
  int x,y,i=0;
  top=0;
  char data[100];
  /*while(1){
    scanf("%c",&data);
    if(!((data >= '0' && data <= '9')||data=='+'||data=='-'||data=='*')) break;
    switch(data){
    case '+':
      x=pop();
      y=pop();
      push(x+y);
      break;
    case '-':
      y=pop();
      x=pop();
      push(x-y);
      break;
    case '*':
      x=pop();
      y=pop();
      push(x*y);
      break;
    default:
      push(data);
      break;
    }
    for(i=1;i<=top;i++)
      printf(" &d\n",stack[i]);
      }*/
  while(scanf(" %s",data)==1){
    if(data[0] == '+'){
      x=pop();
      y=pop();
      push(x+y);
    }else if(data[0] == '-'){
      y=pop();
      x=pop();
      push(x-y);
    }else if(data[0] == '*'){
      x=pop();
      y=pop();
      push(x*y);
    }else if(data[i]>='0'&&data[i]<='9') push(atoi(data));
  }
  printf("%d\n",pop());
  return 0;
}

void push(int data){
  top++;
  stack[top]=data;
}

int pop(){
  top--;
  return stack[top+1];
}

