#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

typedef string::const_iterator state;
class parse_error {};

void cmpinc(state &it, char expected) {
	if (*it == expected) {
		it++;
	}
	else {
		cerr << "Expected '" << expected << "',";
		cerr << "got '" << *it << "'";

		cout << endl;
		throw parse_error();
	}
}

char az(char c) {
	return (c - 'A' + 26) % 26 + 'A';
}

/*

EBNF

cipher = {string};
string = letter | '[' cipher ']';
letter = ['+'|'-'](( 'a' - 'Z' ) | '?');

*/

char c;//?????°??¨

string cipher(state &it);
string str(state &it);
char letter(state &it);

bool flag; //?????????????

string cipher(state &it) {
	string ret = "";
	while (*it != '$' && *it != ']') {
		ret += str(it);
	}
	return ret;
}


string str(state &it) {
	string ret = "";
	string t;
	flag = false;

	switch (*it) {
	case '[':
		it++;
		t = cipher(it);
		reverse(t.begin(), t.end());
		ret = t;
		cmpinc(it, ']');
		break;
	default:
		ret = letter(it);
		break;
	}

	return ret;
}

char letter(state &it) {
	char ret = '\0';

	switch (*it) {

	case '+':
		it++;
		ret = az(letter(it) + 1);
		if (flag)ret = '?';
		break;
	case '-':
		it++;
		ret = az(letter(it) - 1);
		if (flag)ret = '?';
		break;
	case '?':
		flag = true;
		ret = *it;
		it++;
		break;
	default:
		if (*it >= 'A'&&*it <= 'Z') {
			ret = *it;
			it++;
		}
		break;
	}

	return ret;
}


int main() {
	for (string s; getline(cin, s), s != "."; ) {
		s += "$";

		state it = s.begin();
		string ans = cipher(it);

		for (size_t f = ans.find("?"); f != string::npos; f = ans.find("?")) {
			ans.replace(f, 1, "A");
		}

		cout << ans << endl;

	}
	return 0;
}