#include<stdio.h>
int stack[10];
int size = 0;
int pop()
{
	return stack[--size];
}
int push(int a)
{
	stack[size++] = a;
}
int digit(char *s)
{
	if (*s == '+' || *s =='-') {
		s++;
		if (*s >= '0' && *s <= '9') return 1;
		return 0;
	}
	if (*s >= '0' && *s <= '9') return 1;
	return 0;
}
int get(char *s)
{
	int sign = 0,n = 0;
	if (*s == '+') {
		s++;
	} else if (*s == '-') {
		sign++;
		s++;
	}
	while (*s >= '0' && *s <= '9') {
		n = *s - '0';
		s++;
	}
	if(sign) return -n;
	return n;
}
int calc(char *s)
{
	int a,b,n;
	while (*s) {
		if (digit(s)) {
			n = get(s);
			push(n);
			while (*s == '-' || *s == '+') {
				s++;
			}
			while(n) s++;
		}
		else{
			switch(*s){
			case '+':
				a = pop();
				b = pop();
				push(b+a);
				break;
			case '-':
				a = pop();
				b = pop();
				push(b-a);
				break;
			case '*':
				a = pop();
				b = pop();
				push(b*a);
				break;
			}
			s++;
		}
	}
	return pop();
}
int main()
{
	char s[100];
	scanf("%[^\n]*s",s);
	printf("%d\n",calc(s));
	return 0;
}
