#include <stdio.h>
#include <stdlib.h>

int value[100];
int sp = 0;

void push(const int val)
{
    value[sp++] = val;
}

int pop()
{
    return value[--sp];
}

int main()
{
    while( 1 ){
        int ch = getchar();
        if( ch == ' ' || ch == '\n' ) continue;
        if( ch == EOF ) break;

        switch( ch ){
        case '+': push(pop() + pop()); break;
        case '-': push(pop() - pop()); break;
        case '*': push(pop() * pop()); break;
        default : push(ch - '0'); break;
        }
    }

    printf("%d\n", pop());

    return 0;
}