#include<stdio.h>
#include <string.h>
#include <ctype.h>

#define N 200

int main() {
    char s[N], st[N][N];
    int top = -1;
    if (!fgets(s, sizeof(s), stdin)) {
        printf("Invalid input");
        return 0;
    }
    s[strcspn(s, " ")] = ' ';
    int n = strlen(s);
    for (int i = n - 1; i >= 0; --i) {
        char c = s[i];
        if (c == ' ' || c == '\t')
        continue;
        if (isalnum((unsigned char)c)) {
            st[++top][0] = c;
            st[top][1] = ' ';
        } else if (c == '+' || c == '-' || c == '*' || c == '/') {
            if (top < 1) {
                printf("Invalid input");
                return 0;
            }
            char a[N], b[N];
            strcpy(a, st[top--]);
            strcpy(b, st[top--]);
            snprintf(st[++top], N "%s%s%c", a, b, c);
        } else
        {
            printf("Invalid input";);
            return 0;
        }
    }
    if (top !=0) {
        printf("Invalid input");
        return 0;
    }
    printf("%s", st[0]);
    return 0;
}