#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										/* 1?????????????´?											*/
#define SECOND_ITEM 1										/* 2?????????????´?											*/
#define EXIT_SUCCESS 0										/* ??£?????????????????????										*/
#define NEXT_ITEM( x ) ( ( x ) + 1 )						/* 1????????????											*/

static void push( signed long slW_Dpush_calc );				/* ??????????????????????????\????????¢??°							*/
static signed long pop( void );								/* ???????????????????????????????????¢??°							*/
static void plus( void );									/* ????´??????????????????¢??°									*/
static void minus( void );									/* ????´??????????????????¢??°									*/
static void multi( void );									/* ????´??????????????????¢??°									*/

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

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

	/* EOF?????\?????????????????§????????? */
	while( scanf( "%s", aulW_Dform ) != EOF ){
		/* ??°????????????1?????????????´???????+????????´??? */
		if( aulW_Dform[ FIRST_ITEM ] == '+' ){
			plus();											/* ????????¢??°????????¶										*/
		}
		/* ??°????????????1?????????????´???????-????????´??? */
		else if( aulW_Dform[ FIRST_ITEM ] == '-' ){
			minus();										/* ????????¢??°????????¶										*/
		}
		/* ??°????????????1?????????????´???????*????????´??? */
		else if( aulW_Dform[ FIRST_ITEM ] == '*' ){
			multi();										/* ????????¢??°????????¶										*/
		}
		else{
			slW_Dcalc = atoi( aulW_Dform );					/* ??°????????°??????????????????									*/
			push( slW_Dcalc );								/* ???????????\??¢??°????????¶									*/
		}
	}
	printf( "%d\n", aslG_Dstack[ SECOND_ITEM ] );			/* ?¨???????????????????										*/
	return EXIT_SUCCESS;
}

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 ) ];		/* ???????????????????????????????????´??????1?????????????´??????????		*/
}

static void plus( void )
{
	signed long slW_Dcalc_first = VER_INIT;					/* 1??????????¨????????´?										*/
	signed long slW_Dcalc_second = VER_INIT;				/* 2??????????¨????????´?										*/
	signed long slW_Dver_throw = VER_INIT;					/* ?¨?????????????????????°										*/

	slW_Dcalc_first = pop();								/* ?????????????????????????????????1??????????¨????????´???¨??????			*/
	slW_Dcalc_second = pop();								/* ?????????????????????????????????2??????????¨????????´???¨??????			*/
	/* ?¨?????????????????????°??????1??????????¨????????´???¨2??????????¨????????´????????????????????????£??\ */
	slW_Dver_throw = slW_Dcalc_second + slW_Dcalc_first;
	push( slW_Dver_throw );									/* ?¨?????????????????????°?????????????????????????????\??????				*/
}

static void minus( void )
{
	signed long slW_Dcalc_first = VER_INIT;					/* 1??????????¨????????´?										*/
	signed long slW_Dcalc_second = VER_INIT;				/* 2??????????¨????????´?										*/
	signed long slW_Dver_throw = VER_INIT;					/* ?¨?????????????????????°										*/

	slW_Dcalc_first = pop();								/* ?????????????????????????????????1??????????¨????????´???¨??????			*/
	slW_Dcalc_second = pop();								/* ?????????????????????????????????2??????????¨????????´???¨??????			*/
	/* ?¨?????????????????????°??????2??????????¨????????´???????1??????????¨????????´????????????????????????£??\ */
	slW_Dver_throw = slW_Dcalc_second - slW_Dcalc_first;
	push( slW_Dver_throw );									/* ?¨?????????????????????°?????????????????????????????\??????				*/
}

static void multi( void )
{
	signed long slW_Dcalc_first = VER_INIT;					/* 1??????????¨????????´?										*/
	signed long slW_Dcalc_second = VER_INIT;				/* 2??????????¨????????´?										*/
	signed long slW_Dver_throw = VER_INIT;					/* ?¨?????????????????????°										*/

	slW_Dcalc_first = pop();								/* ?????????????????????????????????1??????????¨????????´???¨??????			*/
	slW_Dcalc_second = pop();								/* ?????????????????????????????????2??????????¨????????´???¨??????			*/
	/* ?¨?????????????????????°??????1?????????????´???¨2?????????????´????????????????????????£??\ */
	slW_Dver_throw = slW_Dcalc_second * slW_Dcalc_first;
	push( slW_Dver_throw );									/* ?¨?????????????????????°?????????????????????????????\??????				*/
}

Measured memory_bytes: 548