#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)

typedef vector<int> vi;

string parse(string x, int &i)
{
	if (x.length() == i) return "";

	if ('A' <= x[i] && x[i] <= 'Z')
	{
		char c = x[i];
		i++;
		return c + parse(x, i);
	}
	else if (x[i] == ']')
	{
		i++;
		return "";
	}

	i++;
	string s = parse(x, i);
	reverse(s.begin(), s.end());

	return s + parse(x, i);
}

string pre(string x)
{
	int d = 0;
	string ret = "";
	rep(i, 0, x.length())
	{
		if ('A' <= x[i] && x[i] <= 'Z')
		{
			int j = x[i] - 'A';
			while (d < 0) d += 26;
			j = (j + d) % 26;
			ret += char('A' + j);
			d = 0;
		}
		else if (x[i] == '?')
		{
			d = 0;
			ret += "A";
		}
		else if (x[i] == '+')
			d++;
		else if (x[i] == '-')
			d--;
		else
			ret += x[i];
	}
	return ret;
}

int main()
{
	while (1)
	{
		string s; cin >> s;
		if (s[0] == '.') return 0;

		int i = 0;
		string ans = parse(pre(s), i);
		cout << ans << endl;
	}
}