#include <stdio.h>
#include <stdlib.h>
 
int main(){
  int stack[101], s_top = 0, x, i;
  char n;
 
  for(i = 0;i < 199; i++){ 
    scanf("%s" ,&n);
    if(n == '+'){
      s_top -= 1;
      x = stack[s_top];
      x += stack[s_top + 1];
    }
    else if(n == '-'){
      s_top -= 1;
      x = stack[s_top];
      x -= stack[s_top + 1];
    }
    else if(n == '*'){
      s_top -= 1;
      x = stack[s_top];
      x *= stack[s_top + 1];
    }
    else{
      x = atoi(&n);
      s_top += 1;
    }
    stack[s_top] = x;
  }
  printf("%d %d\n" ,stack[s_top], s_top);
  return 0;
}