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

int top,S1[200];

void initialize(){
top = 0;
}

/*int isEmpty(){
if(top == 0)
  return 1;
  }*/

/*void push(int y, int *S){
top++;
S[top] = y;
}*/

void push(int x){
S1[++top] = x;
}

/*int pop(int *S){
if(isEmpty)
  fprintf(stderr,"underflow\n");

top--;
return S[top+1];
}*/

int pop(){
top--;
return S1[top+1];
}


int main(){
int a,b;
char S[200];
int i /*,S1[200]*/;

initialize();

/*for(i = 0; i < 200; i++){
  S[i] = '0';
  S1[i] = 0;
  }*/

  
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("check1 %s\n",S);

    if(S[0] != '+' || S[0] != '-' || S[0] != '*' ){

    printf("checkA %s\n",S);
    printf("atoi %d\n",atoi(S));
    S1[n] = atoi(S);
    }*/


 
/* for(i = 0; i < n; i++){
   if(S[i] == '+'){
   x = pop(S);
   x += pop(S);
   push(x,S);
   }

   else if(S[i] == '-'){
   x = pop(S);
   x -= pop(S);
   push(x,S);
   }

   else if(S[i] == '*'){
   x = pop(S);
   x *= pop(S);
   push(x,S);
   }

   else push(S[i],S); 

   }*/

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

return 0;
}