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

int S[MAX];
int top=0;

void initialize(){
   top = 0;
 }

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

 void push(int x){
   if(isFull()==0){
     fprintf(stderr,"Push ERROR\n");
     exit(1);
   }
   top++;
   S[top] = x;_
}

int pop(){
    if (isEmpty()==0){
      fprintf(stderr,"Pop ERROR\n");
      exit(2);
    }
      top--;
      return S[top+1];
}

int main(void){
  int num, Masato1, Masato2, N;
  char C[100];

  initialize();

  while(scanf("%s", C)!=EOF){

    if('1'<=C[0]&&C[0]<='9')num=1;
    else if(C[0]=='+')num=2;
    else if(C[0]=='-')num=3;
    else if(C[0]=='*')num=4;
    else {
      fprintf(stderr,"Input ERROR\n");
      exit(3);
    }
    switch(num){
      case 1:/*数字*/
      N=atoi(C);
      push(N);
      break;

      case 2:/*足し算*/
      Masato1=pop();
      Masato2=pop();
      push(Masato1+Masato2);
      break;

      case 3:/*引き算*/
      Masato2=pop();
      Masato1=pop();
      push(Masato1-Masato2);
      break;

      case 4:/*掛け算*/
      Masato1=pop();
      Masato2=pop();
      push(Masato1*Masato2);
      break;
    }
    Masato1=0;
    Masato2=0;
  }
  printf("%d\n",pop());

  return 0;
}
