#include<stdio.h>
#define MAX 1000

int top;
int S[MAX];

void initialize(){
       top=0;
       }

void isempty(){
       if(top==0)return;
       }

void isfull(){
       return top>MAX-1;
       }

void pop(int n){
       isfull()return;

       top++;
       S[top]=n;
       }

int push(){
       isempty()return;

       top--;
       return S[top+1];
       }

int main(){
       int i,j,x,y,z;
       char op;
       for(i=0;i != EOF ;i++){
                   scanf("%c",&op);
                   if(op=='+'){
                               x=pop();
                               y=pop();
                               z=x+y;
                               push(z);
                               }
                   else if(op=='-'){
                               x=pop();
                               y=pop();
                               z=x-y;
                               push(z);
                               }
                   else if(op=='*'){
                               x=pop();
                               y=pop();
                               z=x*y;
                               push(z);
                               }
                   else {push(atoi(op));}
                   }
          printf("%d\n",pop());
          return 0;
          }


