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

void initialize();
int isEmpty();
int isFull();
void push(int x);
int pop();

int top;
int s[101];

int main()
{
  char x;
  int n;
  int i,j;
  int count=0;
  int sum=0;

  initialize();

  while(scanf("%c",&x) != EOF){
    switch(x){

    case' ':
      sum = 0;
      if(count > 1){
	for(i=0; i<count; i++){
	  n = 1;
	  for(j=1; j<=i; j++){
	    n *= 10;
	  }
	  sum += pop()*n;
	}
	push(sum);
      }
      count = 0;
      break;
 
    case'+':
      push(pop() + pop());
      break;
    
    case'-':
      n = pop();
      push(pop() - n);
      break;

    case'*':
      push(pop() * pop());
      break;

    case'\n':
      printf("%d\n",s[top]);
      exit(0);
      break;

    default:
      push(atoi(&x));
      count++;
      break;
    }
  }
  
    return 0;
}

void initialize(){
  top = 0;
}

int isEmpty(){
  return top == 0;
}

int isFull(){
  return top >= 100;
}

  
void push(int x){
  if(isFull()){
    exit(0);
  }
  top++;
  s[top] = x;
} 

int pop(){
  if(isEmpty()){
    exit(1);
  }
  top--;
  return s[top+1];
}

