#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];
	fgets( input, 200, stdin );
	int size = strlen( input );
	int i = 0;
	int a, b;
	char *tmpa;

	while ( i < size )
	{
		if ( input[i] == '+' )
		{
			a = pop();
			b = pop();
			push( a + b );
		}
		else if ( input[i] == '-' )
		{
			a = pop();
			b = pop();
			push( b - a );
		}
		else if ( input[i] == '*' )
		{
			a = pop();
			b = pop();
			push( a * b );
		}
		else
		{
			tmpa = &input[i];
			push( atoi( tmpa ) );
		}
		i = i + 2;
	}

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

	return 0;
}