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

int main() {
	int m = 1;
	for (int i = 0; i < m; i++)
	{
		char line[1000];
		char t = getchar();
		int cnt = 0;
		while(t != '\n') {
		    line[cnt] = t;
		    t = getchar();
		    cnt++;
		}
		int mark = 0, exception = 0, negative = 0;
		int array[1000];
		for (int j = 0; j < 1000; j++) array[j] = 0;
		for (int j = 0; j < 1000; j++)
		{
			if (line[j] == 0) break;
			if (line[j] == ' ') continue;
		    if (line[j] == '+') 
		    {
			    array[mark - 1] = array[mark] + array[mark - 1];
			    mark = mark - 1;
		    }
		    else if (line[j] == '-') 
		    {
		    	if (line[j+1] == ' ' || line[j+1] == 0)
			    {
			    	array[mark - 1] = array[mark - 1] - array[mark];
			        mark = mark - 1;
			    }
			    else negative = 1;
		    }
		    else if (line[j] == '*') 
		    {
			    array[mark - 1] = array[mark] * array[mark - 1];
			    mark = mark - 1;
		    }
		    else if (line[j] == '/') 
		    {
		    	if (array[mark] == 0)
		    	{
		    		exception = 1;
		    		break;
		    	}
			    array[mark - 1] = array[mark - 1] / array[mark];
			    mark = mark - 1;
		    }
		    else if (line[j] == '!') 
		    {
		    	if (array[mark] < 0)
		    	{
		    		exception = 2;
		    		break;
		    	}
		    	for (int k = array[mark] - 1; k > 0; k--) array[mark] = array[mark] * k;
		    }
		    else
		    {
		    	mark = mark + 1;
		    	array[mark] = 0;
		    	while(1)
		    	{
		    		if (line[j] == ' ') break;
		    		array[mark] = array[mark] * 10 + (line[j] - 48);
		    		j++;
		    	}
		    	if (negative == 1)
		    	{
		    		array[mark] = 0 - array[mark];
		    	    negative = 0;
		    	}
		    }
		}
		if (exception == 0) printf("%d\n", array[mark]);
		if (exception == 1) printf("division by zero\n");
		if (exception == 2) printf("factorial of an negative number\n");
	}
	return 0;
}
