#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#define MAXLENGTH_STRING 100
#define MAXDEPTH_STACK 100
int stack[MAXDEPTH_STACK];
int top=0;
void push(int num){stack[top++] = num;}
int pop(){return stack[--top];}
int main()
{
    char str[MAXLENGTH_STRING];
    int a=0;
    while(scanf("%s", str)!=EOF)
    {
        if(isdigit(str[0])){push(atoi(str));}
        if(str[0]=='+'){push(pop()+pop());}
        if(str[0]=='-'){a=pop();push(pop()-a);}
        if(str[0]=='*'){push(pop()*pop());}
    }
    printf("%d\n", stack[0]);
    return 0;
}

