#include "bits/stdc++.h"
using namespace std;
string Cipher(int &pos, string &S);
string String(int &pos, string &S);
char Letter(int &pos, string &S);
string Cipher(int &pos, string &S) {
	string ret = "";
	while (1) {
		ret += String(pos, S);
		if (S[pos] == ']' || pos >= S.size()) break;
	}
	return ret;
}
string String(int &pos, string &S) {
	if (S[pos] == '[') {
		pos++;
		string s = Cipher(pos, S);
		pos++;
		reverse(s.begin(), s.end());
		return s;
	}
	else {
		char ch = Letter(pos, S);
		return string(1, ch);
	}
}
char Letter(int &pos, string &S) {
	if (S[pos] == '+') {
		pos++;
		char ch = Letter(pos, S);
		if (ch == '?') return ch;
		ch -= 'A';
		(ch += 1) %= 26;
		return ch + 'A';
	}
	else if (S[pos] == '-') {
		pos++;
		char ch = Letter(pos, S);
		if (ch == '?') return ch;
		ch -= 'A';
		(ch += 25) %= 26;
		return ch + 'A';
	}
	char ch = S[pos];
	pos++;
	return ch;
}
int main() {
	string S;
	while (cin >> S, S != ".") {
		int pos = 0;
		string T = Cipher(pos, S);
		for (int i = 0; i < T.size(); i++) if (T[i] == '?') T[i] = 'A';
		cout << T << endl;
	}
}
