#include <stdio.h>
int main(void){
   char a[100];
   int A[100];
   int i=0,j,back=0;
   while(scanf("%c",&a[i])!=EOF){
       i++;
   }
   for(j=0;j<i;j++){
       if(a[j]!=' '){
           if(a[j]>='0'&&a[j]<='9') {
               if(j!=0) back++;
               A[back]=a[j]-'0';
           }
           else if(a[j]=='+') {
               A[back-1]=A[back-1]+A[back];
               back--;
           }
            else if(a[j]=='*') {
                A[back-1]=A[back-1]*A[back];
                back--;
            }
            else if(a[j]=='-') {
                A[back-1]=A[back-1]-A[back];
                back--;
            }
       }
   }
   printf("%d",A[0]);
   return 0;
}



