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

void push(int);
int pop(void);

int stack[N];
int top = 0;

int main(){
  char data;
  int num, status, i, j, k, count = 0;

  while(1)
    {
      status = scanf("%c",&data);
      
      if(status != 1) break;
      
      if(data == ' ')
	{
	  count = 0;
	  continue;
	}
      
      if(data <= '9' && data >= '0')
	{
	  num = data - 48;
	  count++;
	  
	  if(count >= 2)num = pop()*10 + num;
	  
	  push(num);
	}
      
      if(data == '+' || data == '-' || data == '*')
	{
	  count = 0;
	  i = pop();
	  j = pop();
	  
	  if(data == '+') k = j + i;
	  if(data == '-') k = j - i;
	  if(data == '*') k = j * i;

	  push(k);
	}
    }
  printf("%d\n",stack[0]);
  return 0;
}

void push(int data)
{
  if(top == N) exit(2);
  stack[top] = data;
  top++;
}

int pop(void)
{
  if(top == 0) exit(3);
  top--;
  return stack[top];
}













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

int n_array[N], tail = 0 , i = 0, cnt;;
char c_array[10000];
void calculator(int, int, char);
void number();

int main(){
  
  int num1, num2, j, flag;

  scanf("%s",&c_array);

  while(1)
    {
      number();

    }
  
  printf("%d",n_array[0]);
  
  return 0;
}

void calculator(int a, int b, char sym){

  if(sym == '+')n_array[tail - 1] = a + b;
  if(sym == '-')n_array[tail - 1] = a - b;
  if(sym == '*')n_array[tail - 1] = a * b;
  
  tail--;
}
*/

