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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

typedef string::const_iterator state;

string cipher(state& begin);
string str(state& begin);
string letter(state& begin);

string cipher(state& begin){
    string res;
    while(*begin=='+' or *begin=='-' or ('A'<=*begin and *begin<='Z') or *begin=='?' or *begin=='[') res+=str(begin);
    return res;
}

string str(state& begin){
    string res;
    if(*begin=='['){
        ++begin;
        res=cipher(begin);
        ++begin;
        reverse(res.begin(),res.end());
    }else res=letter(begin);
    return res;
}

string letter(state& begin){
    int x=0;
    string res;
    while(true){
        if(*begin=='+'){
            ++x;
            ++begin;
        }else if(*begin=='-'){
            --x;
            ++begin;
        }else if(*begin=='?'){
            res='A';
            ++begin;
            break;
        }else{
            res='A'+(*begin-'A'+x+26*100)%26;
            ++begin;
            break;
        }
    }
    return res;
}

void solve(){
    while(true){
        string s;
        cin >> s;
        if(s==".") break;
        state begin=s.begin();
        cout << cipher(begin) << endl;
    }
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    solve();
    return 0;
}