// editor2
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#define max 100
int stack[max];
int top=-1;
void push(int x){
    if(top==max-1){
        printf("Stack overflow");
    }
    stack[++top]=x;
}
void pop(){
    if(top==-1){
        printf("Stack underflow");
        return;
    }
    top--;
}
int isValid(ch){
    if(ch=='+'||ch=='-'||ch=='*'||ch=='/'){
        return 1;
    }
}
int isalnum(ch){
    return (ch=='+'|| ch=='-'||ch=='*'||ch='/');
}
void function(char *str){
    int len=strlen(str),ind;
    for(ind=len-1;ind>=0;ind--){
        char ch=str(ind);
        if(!isValid(ch)){
            printf("Invalid input");
            return;
        }
        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(len);
            res[l]=ch;
            res[l+1]='\0';
            push(res);
        }
    }
    printf("%s",stack[top]);
    
}
int main(){
      int x;
      scanf("%d",&x);
      char *str[20],ch;
      function(str);
      return 0;
      }