#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

typedef string::const_iterator state;

string Cipher(state &begin);
string String(state &begin);
string Letter(state &begin);

string Letter(state &begin){
	string s;
	int count = 0;
	while(1){
		if(*begin=='+'){
			count +=1;
			begin++;
		}else if(*begin=='-'){
			count -=1;
			begin++;
		}else{
			break;
		}
	}
	char k = *begin;
	begin++;
	if(k=='?'){
		k = 'A';
	}else if(k+count>'Z'){
		k = 'A'+(k+count-'Z'-1)%26;
	}else if(k+count<'A'){
		k = 'Z'-('A'-k-count-1)%26;
	}else{
		k += count;
	}
	s.push_back(k);
	return s;
}

string String(state &begin){
	if(*begin =='['){
		begin++;
		string s = Cipher(begin);
		reverse(s.begin(),s.end());
		begin++;
		return s;
	}else{
		string s = Letter(begin);
		return s;
	}
}

string Cipher(state &begin){
	string s;
	while(1){
		if(*begin =='['){
			s += String(begin);
		}else if((*begin>='A'&&*begin<='Z')||*begin=='+'||*begin=='-'||*begin=='?'){
			s += Letter(begin);
		}else{
			break;
		}
	}
	return s;
}



int main(){
	string s;
	while(cin>>s && s!="."){
		state begin = s.begin();
		cout << Cipher(begin) << endl;
	}
	return 0;
}