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

typedef struct{
  int *INFO;
  int TOP;
}Stack;

#define top(s) (s).TOP
#define infotop(s) (s).INFO[top(s)]

void push(Stack *s,int x)
{
  top(*s)++;
  infotop(*s) = x;
}

void pop(Stack *s,int *x)
{
  if(!top(*s)){
    (*x) = 0;
    return;
  }
  (*x) = infotop(*s);
  top(*s)--;
}

void init(Stack *s,int sizes)
{
  top(*s) = 0;
  (*s).INFO = calloc(sizes,sizeof(int));
}

void split(char *data,int *result,char split_by)
{
  int n,i,j,k;
  char temp[100];
  Stack s;
  init(&s,strlen(data));
  result = calloc(strlen(data),sizeof(int));
  for(n = i = j = 0; data[n] != '\0'; n++){
    if(data[n] == split_by){
      temp[i] = '\0';
      if(temp[0] != '+' && temp[0] != '-' && temp[0] != '*' && temp[0] != '/'){
        push(&s,atoi(temp));
      }
      else{
        pop(&s,&j);
        pop(&s,&k);
        if(temp[0] == '+')
          push(&s,k+j);
        else if(temp[0] == '-')
          push(&s,k-j);
        else if(temp[0] == '*')
          push(&s,k*j);
        else
          push(&s,k/j);
      }
      i = 0;
      continue;
    }
    temp[i++] = data[n];
  }
  while(top(s) > 1){
    pop(&s,&j);
    pop(&s,&k);
    if(temp[0] == '+')
      push(&s,k+j);
    else if(temp[0] == '-')
      push(&s,k-j);
    else if(temp[0] == '*')
      push(&s,k*j);
    else
      push(&s,k/j);
  }
  pop(&s,&k);
  printf("%d\n",k);
}

int main(){
  int x;
  int *temp;
  char s[100];
  while( scanf("%[^\n]",s) != EOF )
    split(s,temp,(char)' ');
  return 0;
}

