#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<functional>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define RREP(i, a, n) for(int i=n-1; i>=a; i--)
#define INF 1000000000
#define ll long long


int main()
{
	string S;
	while (cin >> S, S != ".") {
		int cnt = 0, idx = 0;
		char ans[101];
		stack<int> stk;

		REP(i, 0, S.size()) {
			if (S[i] == '+') cnt++;
			else if (S[i] == '-') cnt--;
			else if (S[i] == '?') {
				ans[idx] = 'A';
				idx++;
				cnt = 0;
			}
			else if (S[i] == '[') {
				stk.push(idx);
			}
			else if (S[i] == ']') {
				int begin = stk.top(), end = idx - 1;
				stk.pop();
				while(end - begin > 0) {
					swap(ans[begin], ans[end]);
					begin++;
					end--;
				}
			}
			else {
				cnt %= 26;
				char tmp = S[i] + cnt;
				if (tmp > 'Z') {
					tmp = tmp - 26;
				}
				if (tmp < 'A') {
					tmp = tmp + 26;
				}
				ans[idx] = tmp;
				idx++;
				cnt = 0;
			}
		}

		ans[idx] = '\0';
		cout << ans << endl;
	}

	return 0;
}