#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SIZE  100   
int count=0;        
typedef struct node{
 char value;
 struct stack *next;
 struct stack *prev;
}stack;

stack *bottom=NULL;
stack *top=NULL;

stack *createnode(char a)
{
 stack *newstack;
 newstack=(stack*)calloc(1,sizeof(stack));
 newstack->value=a;
 newstack->prev=NULL;
 newstack->next=NULL;
 return newstack;
}

int isempty()
   {
       if(count==0)
       {return 1;}
       else
       {return 0;}
    }

int isfull()
    {
     if(count==SIZE)
     {return 1;}
     else
     {return 0;}
    }

void push(char a) 
{   if(isfull()==1) 
   {
    printf("overflow condition: stack full");
   }
 else               
   {count+=1;       
 stack *newstack = createnode(a);
 if(bottom==NULL)   
 {
 bottom=newstack;
 top=bottom;
 }
 else               
 {
  top->next=newstack;
  newstack->prev=top;
  top=newstack;
 }
   } 
}
char peek()         
{ 
   	return top->value;
}
char pop()        
    {   if(isempty()==1)          
        {
         printf("underflow condition:empty stack");
        }
        else 
        {if(count==1)             
        {   char c;
         c=top->value;
         top=NULL;
         bottom=NULL;
         count=count-1;
         return c;
         
        }
        else                           
     {char c;
     c=top->value;
  top=top->prev;
  top->next=NULL;
  count=count-1;
  return c;
  
     }
       } 
    }
    char plus=43;
    char multi=42;
    char divi=47;
    char power=94;
    char left=40;
    char right=41;
    char subtract=45;
int precedence(char c)
{  int precide=0;
	if(c==subtract)
	{precide+=0;}
	if(c==plus)
	{precide+=1;}
	if(c==multi)
	{precide+=2;}
	if(c==divi)
	{precide+=3;}
	if(c==power)
	{precide+=4;}
	if(c==left || c==right)
	{precide+=5;}
	return precide;
	precide=0;
}
 
char *postfix_converter(char *string,int length)
{ char s[100]="\0"; int i; stack operators;
	for(i=0;i<length;i++)
	{   
		char c; 
		c=string[i];
		if(c==plus || c==subtract || c==multi || c==divi || c==power || c==left)
		{
		  if(top==NULL)
		  {
		  	push(c);
		  }
		  else
		  {
		  	if(precedence(c)>precedence(peek()) || peek()==left)
		  	{
		  		push(c);
		  	}
		  	else
		  	{  
		  		char r[2]="\0";
		  	    r[0]=pop();
		  	    strcat(s,r);
		  	    push(c);
		  	}
 
		  }
		}
		else
		{
			if(c==right)
			{
			 while(peek()!=left)
			 {
			    char r[2]="\0";
		  	    r[0]=pop();
		  	    strcat(s,r);
			 }
			 pop();
			}
			else
			{
			    char r[2]="\0";
		  	    r[0]=c;
		  	    strcat(s,r);
		  	 //  printf("%s\n",s);
		  	//  char j=peek();
		  	//  printf("%c",j);
		  	
			}
		}
		if(i==(length-1))
		{// printf("%d",count);
		  while(count>0)
		  {
		  	 char r[2]="\0";
		  	    r[0]=pop();
		  	    strcat(s,r);
		 // 	    printf("lool");
		  }
		}
		  	 
		//	printf("%d\n",count);
		//	printf("%s\n",s);
  	}
 
	//printf("%d\n",pop());
   printf("%s",s);
}
 
// driver code , the main function
 
int main(void)
{   char inversion[200]; 
	printf("give the infix expression\n");
	scanf("%s",&inversion);
	int longer=strlen(inversion);
	postfix_converter(inversion,longer);

	return 0;
}