#include "bits/stdc++.h"
using namespace std;
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2584&lang=jp
string Chiper(int& x, string& S);
char Letter(int& x, string& S);

string Chiper(int& x, string& S) {
	string ret = "";
	for (; x < S.length();x++) {
		if (S[x] == ']')return ret;
		if (S[x] == '[') {
			x++;
			string temp = Chiper(x, S);
			reverse(temp.begin(), temp.end());
			ret += temp;
		}
		else {
			ret += Letter(x, S);
		}
	}
	return ret;
}

char Letter(int& x, string& S) {
	int cnt = 0;
	char ret = '\n';
	for (;x < S.length();x++) {
		if (S[x] == '+') { cnt++; continue; }
		if (S[x] == '-') { cnt--; continue; }
		if (S[x] == '?') { return 'A'; }
		ret = (S[x] - 'A' + cnt + 26 * 5) % 26 + 'A';
		return ret;
	}
	return ret;
}

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	string S;
	while (cin >> S) {
		if (S == ".")break;
		int x = 0;
		cout << Chiper(x, S) << endl;
	}
}