#include <bits/stdc++.h>
using namespace std;

string s;

string rec(int &pos){
    string res = "";
    while(1){
        // end
        if(pos >= int(s.size()) || s[pos] == ']'){
            return res;
        }
        // begin Cipher
        if(s[pos]=='['){
            pos++;
            string tmp = rec(pos);
            reverse(tmp.begin(), tmp.end());
            res += tmp;
            pos++;
            continue;
        }
        int cnt = 0;
        // count +-
        while(1){
            if(s[pos]=='+') cnt++;
            else if(s[pos]=='-') cnt--;
            else break;
            pos++;
        }
        // Add Letter
        if(s[pos] == '?') res.push_back('A');
        else res.push_back(char('A'+((s[pos]-'A')+cnt%26+26)%26));
        pos++;
    }
}

int main() {
    while(cin >> s, s!="."){
        int i=0;
        cout << rec(i) << endl;
    }
    return 0;
}



