#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;

int
main(int argc, char *argv[])
{
  int q[100000];
  char s[100000];
  fgets(s, 99999, stdin);

  int n = strlen(s);

  int qi = 0; int i = 0;
  while(i < n){
    if(s[i] == '+'){
      q[qi - 2] = q[qi - 2] + q[qi - 1];
      qi--; i += 2;
    }
    else if(s[i] == '-'){
      q[qi - 2] = q[qi - 2] - q[qi - 1];
      qi--; i += 2;
    }
    else if(s[i] == '*'){
      q[qi - 2] = q[qi - 2] * q[qi - 1];
      qi--; i += 2;
    }
    else{
      int k = 0; int d = 1000000;
      while(s[i] != ' '){
	k += (int)(s[i] - '0') * d;
	d /= 10;
	i++;
      }
      q[qi] = k / (d * 10);
      qi++;
      i++;
    }
  }

  printf("%d\n", q[qi - 1]);

  return 0;
}
       

