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

void my_push(int);
int my_pop(void);
int count=0;
int stack[100];

int main(void){

  int a,b;
  int i;
  char s[100];

  while(scanf("%s", s) != EOF ) {
    
    printf("%d\n",(int)strlen(s));
    for(i=0;s[i] != '\0';i++){
      if ( s[i] == '+' ){
	a = my_pop();
	b = my_pop();
	my_push(b + a);
      } 
      else if ( s[i] == '-' ){
	a = my_pop();
	b = my_pop();
	my_push(b - a);
      } 
      else if ( s[i] == '*' ){
	a = my_pop();
	b = my_pop();
	my_push(b * a);
      } 
      else {
	my_push(atoi(s));
      }
    }
  }
  printf("%d\n",stack[count-1]);
  return 0;
}


void my_push(int x){

  stack[count++] = x;
}

int my_pop(void){

  return stack[--count];
}