#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define N 100

int pop(void);
void push(int);
int tank[N];
int top=0;

int main()
{
 char st[N];
 int a,b,r;

 while(scanf("%s",st)!=EOF)
 {
   if (st[0]=='+')
   {
    a = pop();
    b = pop();
    r = a + b;
    push(r);
   }
   else if(st[0]=='-')
   {
    a = pop();
    b = pop();
    r = b-a;
    push(r);
   }
   else if (st[0]=='*')
   {
    a = pop();
    b = pop();
    r = a*b;
    push(a*b);
   }
   else
   {
    push(atoi(st));
   }
 }
 r = pop();
 printf("%d\n",r);
 return 0;
}

void push(int in)
{
 tank[top]=in;
 top++;
}

int pop(void)
{
 top--;
 return tank[top];
}
