#include <stdio.h>
#include <ctype.h>
int main()
{
 
  int n[100],top=0,keta=0;
  char m;  
  
  
  while( (m = getchar()) != '\n' )  {
    if(isdigit(m)){ 
      if(keta) { 
        n[top] = n[top] * 10 + (m - '0'); 
      } else {
        n[top] = (m - '0');
        keta++;
      }
    }
    if( isspace(m) ) { 
      if(keta) { 
        top++;
        keta = 0;
      }
    }
    if( m == '+' ) { 
      if( top > 1 ) {
        top--;
      }
      n[top-1] += n[top];
      n[top] = 0;
    }
    if( m == '-' ) {
      if( top > 1 ) {
        top--;
      }
      n[top-1] -= n[top];
      n[top] = 0;
    }
    if( m == '*' ) { 
      if( top > 1 ) {
        top--;
      }
      n[top-1] *= n[top];
      n[top] = 0;
    }
    if( m == '/' ) {
     
      if( top > 1 ) {
        top--;
      }
      n[top-1] /= n[top];
      n[top] = 0;
    }
  }
 
  printf("%d\n",n[0]);
  return 0;
}