#include <stdio.h>
#include <stdlib.h>
#define OPERAND 100
#define OPERATER 99

int stack[OPERAND], top = -1;
void push( int ); 
int pop( void ); 


int main (){
    char data[100];
    int fx, lx;// fx means former x, and fy means latter x


    //inputing data, and storing or calculating the data
    while ( scanf("%s", data) != EOF ){
	if (data[0] == '+'){//addition procedure
	    lx = pop();
	    fx = pop();
	    fx = fx + lx;
	    push(fx);
	}
	else if (data[0] == '-'){//subtraction procedure
	    lx = pop();
	    fx = pop();
	    fx = fx - lx;
	    push(fx);
	}
	else if (data[0] == '*'){//multiplication procedure
	    lx = pop();
	    fx = pop();
	    fx = fx * lx;
	    push(fx);
	}
	else {//store the input data
	    push(atoi(data));
	}
    }
    //display the calculation result
    printf("%d\n", pop());

    return 0;
}


void push( int data ){

    //store the data,and update the top number
    top++; //this first number is '-1'
    stack[top] = data;
    

    return ;
}


int pop( void ){
    int retval;

    retval = stack[top];
    top--;

    return retval;
}

