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


string solve(const string& s){
    if(s.size() == 0)
        return "";

    char head = s[0];
    string tail = s.substr(1);

    int p = 0;
    int c = 0;
    //cout << "head" << head << endl;
    if(head == '['){
            int b = 1;
            int i = 1;
            while(b > 0){ // XXX
                if(s[i] == '[')
                    b++;
                else if(s[i] == ']')
                    b--;
                i++;
            }
            string res1 = solve(s.substr(1, i - 2));
            reverse(begin(res1), end(res1));
            return res1 + solve(s.substr(i));
    }else if(head == '+'){
            string res2 = solve(tail);
            if(res2[0] == '?')
                return "?" + res2.substr(1); //XXX
            else{
                if(res2[0] == 'Z'){
                    return "A" +  res2.substr(1);
                }else{
                    return string({(char)(res2[0] + 1)}) +  res2.substr(1);
                }                
            }
    }else if(head == '-'){
        //cout << "-" << endl;
            string res3 = solve(tail);
            if(res3[0] == '?')
                return "?" + res3.substr(1); //XXX
            else{
                //cout << res3[0] << endl;
                if(res3[0] == 'A'){
                    //cout << "hoeg" << endl;
                    return "Z" +  res3.substr(1);
                }else{
                    return string({(char)(res3[0] - 1)}) +  res3.substr(1);
                }
            }
    }else if(head == '?'){            
            return "?" + solve(tail);
    }else{
            return head + solve(tail);
    }
}

int main(){
    string s;
    while(cin >> s, s != "."){
        string res = solve(s);
        for(int i = 0; i < s.size(); i++){
            if(res[i] == '?')
                res[i] = 'A';
        }
        cout << res << '\n';
    }
    return 0;
}