#include<math.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#define  MAX 300

struct stack {
	char alpha;
	struct stack *nxtPTR;

};

typedef struct stack  Stack;
typedef  Stack *node;
void  message(void);
char out_print(char word[]);
int precedence_power(int res_1, int  res_2);
int pop(node *topPtr);
void push_stack(node *topPTR, char value);
int pop(node  *topPTR);
char check_stack(node data);
int isOperator(char c);
int precedence(char data_1, char   data_2, int(intro_precedence_power)(int res_1, int  res_2));
void  converting(char *in, char *out, node *PTR, char (checking_stack)(node), void (push)(node *topPTR, char value), int (pop)(node *fix), int (isOper)(char c), int (precedence_intro)(char data_1, char  data_2, int(intro_precedence_power)(int res_1, int  res_2)), int(intro_precedence_power)(int res_1, int  res_2));
void  please_enter(void );

int main(void) {
	
	char infix[MAX];
	char postfix[MAX];
	node topPTR = NULL;
	
	fgets(infix, sizeof(infix), stdin);
    int	m = strlen(infix);

	infix[m] = ')';

	memset(postfix, 0, MAX);
	

  

	converting( infix, postfix, &topPTR, check_stack, push_stack, pop, isOperator, precedence, precedence_power);
	out_print(postfix);
	
	puts(" ");
	
return 0;
}

char out_print(char word[]) {

if( word[0]  != '\0' ){
	 	printf( "%c " ,  word[0]    ) ; 
return    out_print(word + 1  )  ;
}

}

void push_stack(node *topPTR, char value) {
	node newPTR = malloc(sizeof(Stack));

	if (newPTR != NULL) {

		newPTR->alpha = value;
		newPTR->nxtPTR = *topPTR;

		*topPTR = newPTR;
	}

	else {

		puts("error");

	}
}

int pop(node *fix) {

int value = (*fix)->alpha;

	node temp = *fix;
	*fix = (*fix)->nxtPTR;
	free(temp);

	return value;
}

char check_stack(node data) {
	return data->alpha;
}

int isOperator(char c) {
	return c == '/' || c == '*' || c == '-' || c == '+'  || c == '^'  ;
}

void converting(char *in, char *out, node *PTR, char (checking_stack)(node), void (push)(node *topPTR, char value), int (pop)(node *fix), int (isOper)(char c), int (precedence_intro)(char data_1, char  data_2, int(intro_precedence_power)(int res_1, int  res_2)), int(intro_precedence_power)(int res_1, int  res_2)) {

	int k = 0, j = 0, d = 0;
	
	push(PTR, '(');
	
	for (k = 0; checking_stack((node)PTR) != 0; k++) {
	
		if (isdigit(in[k])) {
			
			out[j++] = in[k];

		}

		if (in[k] == '(') {

			push(PTR, in[k]);

		}

		if (isOper(in[k]) == 1) {

			while (precedence_intro((*PTR)->alpha, in[k], intro_precedence_power) != -1) {

				out[j++] = pop(PTR);
			}

			push(PTR, in[k]);
		}
		
		if (in[k] == ')') {

			d = pop(PTR);
			for (; d != '('; d = pop(PTR)) {
				out[j++] = d;
			}
		}
	}
}





int precedence(char data_1, char   data_2, int(intro_precedence_power)(int res_1, int  res_2))  {
 char collection[] = "+1-1*2/2^3";	
 
 char	buf_1 = (char)strcspn(  collection , &data_1) + 1;
 char	buf_2 = (char)strcspn(collection, &data_2) + 1;

	return   intro_precedence_power(atoi(&collection[buf_1]), atoi(&collection[buf_2]));
}

int precedence_power(int res_1, int  res_2) {
	if (res_1 < res_2) {
		return   -1;
	}
	else	if (res_1 == res_2) {
		return 	  0;
	}
	else	if (res_1 > res_2) {
		return	  1;
	}
	return 0;
}