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

int tmp[100];
int n = 0;

int pop()
{
	n = n - 1;
	return tmp[n];
}

void push( int x )
{
	tmp[n] = x;
	n = n + 1;
}

int main()
{
	char input[200];
	int size = strlen( input );
	int i = 0;
	int a, b;
	char *tmpa;

	while ( scanf( "%s", input ) != EOF )
	{
		if ( input[0] == '+' )
		{
			a = pop();
			b = pop();
			push( b + a );
		}
		else if ( input[0] == '-' )
		{
			a = pop();
			b = pop();
			push( b - a );
		}
		else if ( input[0] == '*' )
		{
			a = pop();
			b = pop();
			push( a * b );
		}
		else
		{
			push( atoi( input ) );
		}
	}

	fprintf( stdout, "%d\n", tmp[n - 1] );

	return 0;
}