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

#define N 100000

int calc(char);
int pop();
void push(int);

int head = 0;
int S[N+1];

int main()
{
  char str[5];
  
  while(scanf("%s",str) != EOF){

    if( str[0] == '+' || str[0] == '-' || str[0] == '*')
      push(calc(str[0]));
    else push(atoi(str));
    
    if(getchar() == '\n'){
      printf("%d\n",pop());
      break;
    }
  }
  return 0;
}

int pop()
{
  return S[--head];
}

void push(int num)
{
  S[head++] = num;
}

int calc(char str){
  int b = pop();
  int a = pop();
  if(str == '+')return a+b;
  else if(str == '-')return a-b;
  else if(str == '*')return a*b;
}


