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

typedef ostringstream OSS; typedef istringstream ISS;
typedef long long LL;
typedef pair<int, int> PII;  typedef pair<LL, LL> PLL;
typedef vector<int>    VI;   typedef vector<VI>   VVI;   typedef vector<VVI>   VVVI;
typedef vector<LL>     VLL;  typedef vector<VLL>  VVLL;  typedef vector<VVLL>  VVVLL;
typedef vector<double> VD;   typedef vector<VD>   VVD;   typedef vector<VVD>   VVVD;
typedef vector<string> VS;   typedef vector<VS>   VVS;   typedef vector<VVS>   VVVS;
typedef vector<bool>   VB;   typedef vector<VB>   VVB;   typedef vector<VVB>   VVVB;
typedef vector<PII>    VPII; typedef vector<VPII> VVPII; typedef vector<VVPII> VVVPII;
typedef vector<PLL>    VPLL; typedef vector<VPLL> VVPLL; typedef vector<VVPLL> VVVPLL;

typedef unsigned int  UI;
typedef vector<UI>    VUI;
typedef vector<VUI>   VVUI;

#define fst first
#define snd second
// #define Y first
// #define X second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define MAXUD(orig, target) orig = max(orig, target)
#define MINUD(orig, target) orig = min(orig, target)
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a)   { OSS oss; oss << a; return oss.str(); };

template<typename T=int> inline void dump(vector<T> vs, bool ent=false) { rep(i, vs.size()) cout << vs[i] << (i+1==vs.size() ? '\n' : ' '); if (ent) cout << endl; }
template<typename T = int> inline void dump(vector<vector<T>> vs, bool ent = false) { rep(i, vs.size()) dump<T>(vs[i]); if (ent) cout << endl; }

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;
const int    DX[] = {1,  0, -1, 0};
const int    DY[] = {0, -1,  0, 1};
const double EPS  = 1e-12;
// const double PI   = acos(-1.0);
// lambda: [](T1 x)->T2{return y;}
// simple lambda: [](T x){return x;}

// value, next
typedef pair<string, int> Res;
Res b_string(string &s, int pos);
Res b_letter(string &s, int pos);
Res b_chipher(string &s, int pos);

char addc(char c, int k) {
    if (c == '?') return c;
    int n = c - 'A';
    n = (n + k + 26) % 26;
    return 'A' + n;
}

Res b_chipher(string &s, int pos) {
    Res x = b_string(s, pos);
    pos = x.snd;
    if (pos == (int)s.size()) {
        return MP(x.fst, pos);
    } else if (s[pos] == ']') {
        return MP(x.fst, pos + 1);
    } else {
        Res y = b_chipher(s, pos);
        return MP(x.fst + y.fst, y.snd);
    }
}

Res b_string(string &s, int pos) {
    char c = s[pos];

    if (c == '[') {
        ++pos;

        Res x = b_chipher(s, pos);
        pos = x.snd;

        reverse(ALL(x.fst));

        return MP(x.fst, pos);
    } else if (c == ']') {
        return MP(string(), pos + 1);
    } else {
        return b_letter(s, pos);
    }
}

Res b_letter(string &s, int pos) {
    string res;
    char c = s[pos];

    if (c == '-') {
        Res x = b_letter(s, pos + 1);
        char c2 = addc(x.fst[0], -1);
        return MP(res + c2, x.snd);
    } else if (c == '+') {
        Res x = b_letter(s, pos + 1);
        char c2 = addc(x.fst[0], +1);
        return MP(res + c2, x.snd);
    } else if (c == '?') {
        return MP(res + '?', pos + 1);
    } else {
        assert(isupper(c));
        return MP(res + c, pos + 1);
    } 
}

string solve(string s) {
    string ans = b_chipher(s, 0).fst;
    for (auto &c : ans) if (c == '?') c = 'A';
    return ans;
}

int main(void) {
    string s;
    while (cin >> s, s != ".") {
        cout << solve(s) << endl;
    }

    return 0;
}

Measured memory_bytes: 3132