// Author :
// Date :
// Problem:
// Solution:
// Comment:

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstring>

#define pp push
#define pb push_back
#define mp make_pair
#define xx first
#define yy second

using namespace std;

string play(string str){
    string ans;
    string q;
    int d = 0;
    
    //cout << str << endl;
    
    for(int i = 0 ; i < str.size() ; i++){
        if(str[i] == '['){
            string strr,strrr;
            
            int cnt = 1;
            while(cnt > 0){
                i++;
                if(str[i] == '[') cnt++;
                else if(str[i] == ']') cnt--;
                
                if(cnt > 0) strr = strr + str[i];
            }
            
            //cout << "strr " << strr << endl;
            strr = play(strr);
            
            for(int j = strr.size()-1 ; j >= 0 ; j--) strrr += strr[j];
            
            ans += strrr;
        }
        if(str[i] >= 'A' && str[i] <= 'Z'){
            while(d < -(26)) d+=26;
            ans += (str[i] + d + 26 - 'A') % 26 + 'A';
            d = 0;
        }
        if(str[i] == '-') d--;
        else if(str[i] == '+') d++;
        
        if(str[i] == '?'){
            d = 0;
            ans += 'A';
        }
    }
    //cout << "ans" << ans << endl;
    
    return ans;
}

int main(){
    string str;
    while(cin >> str){
        if(str[0] == '.') break;
        
        cout << play(str) << endl;
    }
    #ifdef GEREL
        for(;;);
    #endif

    return 0;
}