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

#define MAX 100

static int top = 0;
static int stack[MAX];

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


int main(void){
  char s, xs[7];
  int i, x, c = 0;

  while(c == 0){
    scanf("%c", &s);
    switch(s){
    case '+':
      push(pop()+pop());
      break;
    case '-':
      x = pop();
      push(pop()-x);
      break;
    case '*':
      push(pop()*pop());
      break;
    case '\n':
      c++;
      break;
    default:
      if(isdigit((int)s)){
	i = 0;
	xs[0] = s;
	while(isdigit((int)s)){
	  xs[i] = s;
	  i++;
	  scanf("%c", &s);
	}
	xs[i] = '\0';
	push(atoi(xs));
      }
    }
  }
  printf("%d\n", pop());
  return 0;
}


void push(int x){
  if(isFull()){
    printf("?????????????????????\n");
    exit(1);
  }
  stack[++top] = x;
}


int pop(void){
  if(isEmpty()){
    printf("??¢??????????????????\n");
    exit(1);
  }
  return stack[top--];
}


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


int isFull(void){
  return top >= MAX-1;
}