#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cassert>
using namespace std;

string S;

char step(char ch, int offset) {
    if (ch == '?') return 'A';
    return ((ch - 'A') + offset + 26*1000) % 26 + 'A';
}

pair<string, int> parse(int idx) {
    string res = "";
    while (idx < S.size()) {
        if (S[idx] == ']') {
            reverse(res.begin(), res.end());
            idx ++;
            break;
        }

        if (S[idx] == '[') {
            pair<string, int> sub = parse(idx+1);
            res += sub.first;
            idx = sub.second;
            continue;
        }

        int offset = 0;
        while (S[idx] == '+' || S[idx] == '-') {
            offset += (S[idx] == '+') ? 1 : -1;
            ++idx;
        }

        res += string(1, step(S[idx], offset));
        idx++;
    }

    return make_pair(res, idx);
}

void solve(){
    string res;
    pair<string, int> pr = parse(0);
    cout << pr.first << endl;
}

int main(){
    while(1){
        cin >> S;
        if (S == ".") break;
        solve();
    }
}

