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

#define BUFFER_SIZE 2
#define STACK_SIZE 99

#define TYPE_NUM 1
#define TYPE_ADD 2
#define TYPE_SUB 3
#define TYPE_MUL 4
#define TYPE_DIV 5

typedef struct {
	int type;
	int number;
} Term;

int read_term(Term *p_term, FILE *p_file){
	int ok = 0;
	char buf[BUFFER_SIZE];
	int ch;

	for(;;){
		// Input
		ch = fgetc(p_file);
		if( ch == EOF ){
			break;
		}

		// Check
		if( isdigit( ch ) ){
			ok = 1;
			p_term->type = TYPE_NUM;
			memset( buf, '\0', BUFFER_SIZE * sizeof(char) );
			buf[0] = (char)ch;
			p_term->number = atoi(buf); 
			for(;;){
				ch = fgetc(p_file);
				if( ch == EOF || !isdigit(ch) ){
					break;
				}
				buf[0] = (char)ch;
				p_term->number = p_term->number * 10 + atoi(buf); 
			}
			break;
		} else if( ch == '+' ){
			ok = 1;
			p_term->type = TYPE_ADD;
			break;
		} else if( ch == '-' ){
			ok = 1;
			p_term->type = TYPE_SUB;
			break;
		} else if( ch == '*' ){
			ok = 1;
			p_term->type = TYPE_MUL;
			break;
		} else if( ch == '/' ){
			ok = 1;
			p_term->type = TYPE_DIV;
			break;
		}
	}

	return ok;
}

void process_term(Term *p_term, int *stack, int *p_posi){
		switch(p_term->type){
		case TYPE_NUM:
			stack[(*p_posi)+1] = p_term->number;
			(*p_posi)++;
			break;
		case TYPE_ADD:
			stack[(*p_posi)-1] = stack[(*p_posi)-1] + stack[(*p_posi)];
			(*p_posi)--;
			break;
		case TYPE_SUB:
			stack[(*p_posi)-1] = stack[(*p_posi)-1] - stack[(*p_posi)];
			(*p_posi)--;
			break;
		case TYPE_MUL:
			stack[(*p_posi)-1] = stack[(*p_posi)-1] *+ stack[(*p_posi)];
			(*p_posi)--;
			break;
		case TYPE_DIV:
			stack[(*p_posi)-1] = stack[(*p_posi)-1] / stack[(*p_posi)];
			(*p_posi)--;
			break;
		default:
			break;
		}
}

int main(int argc, char** argv){
	int stack[STACK_SIZE];
	int posi = -1;
	Term term;

	for(;;){
		// Input
		if( !read_term( &term, stdin ) ){
			break;
		}
		// Process
		process_term( &term, stack, &posi );
	}

	// Output
	printf("%d\n", stack[posi]);

	return 0;
}