// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;

#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

char adv_c[26][60];

string cipher(const string &s, ll &idx);
string str(const string &s, ll &idx);
char letter(const string &s, ll &idx);

string cipher(const string &s, ll &idx) {
    string ret;
    while (idx < s.size() && s[idx] != ']') ret += str(s, idx);
    return ret;
}

string str(const string &s, ll &idx) {
    if (s[idx] == '[') {
        idx++;
        string ret;
        while (true) {
            string tmp = cipher(s, idx);
            reverse(ALL(tmp));
            ret += tmp;
            if (s[idx] == ']') break;
        }
        idx++;
        return ret;
    } else {
        return string(1, letter(s, idx));
    }
}

char letter(const string &s, ll &idx) {
    ll cnt = 0;
    while (true) {
        char c = s[idx];
        if ('A' <= c && c <= 'Z') break;
        if (c == '+') cnt++;
        if (c == '-') cnt--;
        idx++;
    }

    {
        bool m = (cnt < 0);
        cnt = abs(cnt) % 26;
        if (m) cnt = -cnt;
    }

    char ret = s[idx];
    idx++;
    return adv_c[ret - 'A'][cnt + 26];
}

bool solve() {
    string S;
    cin >> S;
    if (S == ".") return false;
    V<ll> idx_v;
    for (ll i = 0; i < S.size(); i++) if (S[i] == '?') idx_v.push_back(i);
    ll perm = 1;
    for (ll i = 0; i < idx_v.size(); i++) perm *= 26;
    string ans(S.size(), 'Z');
    for (ll i = 0; i < perm; i++) {
        string cur = S;
        {
            ll cpy = i;
            for (ll idx : idx_v) {
                cur[idx] = 'A' + (cpy % 26);
                cpy /= 26;
            }
        }
        ll idx = 0;
        chmin(ans, cipher(cur, idx));
    }
    cout << ans << endl;
    return true;
}

int main() {
    for (ll i = 0; i < 26; i++) {
        for (ll j = -26; j <= 26; j++) {
            char c = 'A' + i;
            ll cpy = j;
            while (cpy) {
                if (cpy < 0) {
                    c--;
                    cpy++;
                } else if (0 < cpy) {
                    c++;
                    cpy--;
                }
                if (c < 'A') c = 'Z';
                if ('Z' < c) c = 'A';
            }
            adv_c[i][j + 26] = c;
        }
    }
    while (solve());
    return 0;
}



Measured memory_bytes: 3240