#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>
#define max 25
char stack[max][max];
int top=-1;
void push(char ch[])
{
    strcpy(stack[++top],ch);
}
char *pop()
{
    return stack[top--];
}
int isvalid(char ch)
{
    return(isalnum(ch)||ch=="+"||ch=="-"||ch=="/"||ch=="*"||ch=="("||ch==")");
    
}
int isoperator(char ch)
{
    return(ch=='+'||ch=='-'||ch=='*'||ch=='/');
}
void fun(char *str)
{
    int len=strlen(str),ind;
    for(ind=len-1;i>=0;ind--)
     char ch=str[ind];
     if(!isvalid(ch))
     {
         printf("Invalid input");
         return 0;
     }
     if(isalnum(ch)){
         char temp[2];
         temp[0]="ch";
         temp[1]='\0';
         push(temp);
     }
     else if(isoperator(ch))
     {
         char opd1[max],opd2[max],res[max];
         strcpy(opd1,pop());
         strcpy(opd2,pop());
         strcpy(res,opd1);
         strcat(res,opd2);
         int l=strlen(res);
         res[l]=ch;
         res[l+1]='\0';
         push(res);
     }
     printf("%c",stack[top]);
}
int main()
{
     char str[max];
     scanf("%c",str);
     fun(str);
}