#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

string cipher(string const& s, int& p, bool rev);
string str(string const& s, int& p, bool rev);
string letter(string const& s, int& p, bool rev, int cnt);

string cipher(string const& s, int& p, bool rev) {
    string res;
    while(p < s.size() && s[p] != ']') {
        res += str(s, p, rev);
    }
    return res;
}

string str(string const& s, int& p, bool rev) {
    string res;
    if(s[p] == '[') {
        res = cipher(s, ++p, !rev);
        reverse(res.begin(), res.end());
        ++p;
    } else {
        res = letter(s, p, rev, 0);
    }
    return res;
}

string letter(string const& s, int& p, bool rev, int cnt) {
    if(s[p] == '+') {
        return letter(s, ++p, rev, cnt+1);
    } else if(s[p] == '-') {
        return letter(s, ++p, rev, cnt-1);
    } else {
        string res;
        if(s[p] == '?') {
            res += 'A';
            ++p;
        } else {
            int off = s[p] - 'A' + cnt;
            while(off < 0) {
                off += 26;
            }
            res += 'A' + (off % 26);
            ++p;
        }
        return res;
    }
}

int main() {
    string s;
    while(cin >> s, s != ".") {
        int p = 0;
        cout << cipher(s, p, false) << endl;
    }
}
