#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 100
#define MAX 1000

int top,S[MAX];
void initialize();
int isEmpty();
int isFull();
void push(int);
int pop();

int main()
{
  char s[N];
  int a,b;

  while( scanf("%s",s)!=EOF ){
    if( s[0]=='+' ){
      a = pop();
      b = pop();
      push(a+b);
    }
    else if( s[0]=='-' ){
      b = pop();
      a = pop();
      push(a-b);
    }
    else if( s[0]=='*' ){
      a = pop();
      b = pop();
      push(a*b);
    }
    else{
      push(atoi(s));
    }
  }

  printf("%d\n",pop());

  
  return 0;
}

void intialize(){
  top = 0;
}

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

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

void push(int x){
  if (isFull()) printf("overfllow error");
  top++;
  S[top] = x;
}

int pop(){
  if (isEmpty()) printf("underfllow error");
  top--;
  return S[top+1];
}


