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

#define STACK_MAX 1000
#define STACK_INIT 0
#define FORM_MAX 100
#define FORM_INIT 0
#define VER_INIT 0
#define FIRST_ITEM 0
#define SECOND_ITEM 1
#define EXIT_SUCCESS 0
#define NEXT_ITEM( x ) ( ( x ) + 1 )

signed long aslG_Dstack[ STACK_MAX ] = { STACK_INIT };
unsigned long pulG_Dstack_p = VER_INIT;

static void push( signed long slW_Dpush_calc ){
	pulG_Dstack_p++;
	aslG_Dstack[ pulG_Dstack_p ] = slW_Dpush_calc;
}

static signed long pop( void ){
	pulG_Dstack_p--;
	return aslG_Dstack[ NEXT_ITEM( pulG_Dstack_p ) ];
}

static void plus( void ){
	signed long slW_Dcalc_first = VER_INIT;
	signed long slW_Dcalc_second = VER_INIT;
	signed long slW_Dver_throw = VER_INIT;

	slW_Dcalc_first = pop();
	slW_Dcalc_second = pop();
	slW_Dver_throw = slW_Dcalc_first + slW_Dcalc_second;
	push( slW_Dver_throw );
}

static void minus( void ){
	signed long slW_Dcalc_first = VER_INIT;
	signed long slW_Dcalc_second = VER_INIT;
	signed long slW_Dver_throw = VER_INIT;

	slW_Dcalc_first = pop();
	slW_Dcalc_second = pop();
	slW_Dver_throw = slW_Dcalc_first - slW_Dcalc_second;
	push( slW_Dver_throw );
}

static void multi( void ){
	signed long slW_Dcalc_first = VER_INIT;
	signed long slW_Dcalc_second = VER_INIT;
	signed long slW_Dver_throw = VER_INIT;

	slW_Dcalc_first = pop();
	slW_Dcalc_second = pop();
	slW_Dver_throw = slW_Dcalc_first * slW_Dcalc_second;
	push( slW_Dver_throw );
}

int main( void ){
	unsigned char aulW_Dform[ FORM_MAX ] = { FORM_INIT };
	signed long slW_Dcalc = VER_INIT;

	while( scanf( "%s", aulW_Dform ) != EOF ){
		if( aulW_Dform[ FIRST_ITEM ] == '+' ){
			plus();
		}
		else if( aulW_Dform[ FIRST_ITEM ] == '-' ){
			minus();
		}
		else if( aulW_Dform[ FIRST_ITEM ] == '*' ){
			multi();
		}
		else{
			slW_Dcalc = atoi( &aulW_Dform[ FIRST_ITEM ] );
			push( slW_Dcalc );
		}
	}
	printf( "%d\n", aslG_Dstack[ SECOND_ITEM ] );
	return EXIT_SUCCESS;
}