#include <iostream>
#include <string>
#include <stack>
#include <algorithm>

#define rep(i,n) for(int i=0; i<(n); i++)

using namespace std;

string S;
void solve(){
	char ans[100]={};
	stack<int> st;
	int now = 0, sf = 0;
	rep(i,S.length()){
		if( S[i] == '[' ){
			st.push( now );
		}else if( S[i] == ']' ){
			int b = st.top();
			st.pop();
			for(int l=b, r=now-1; r-l>0; l++, r--){
				swap(ans[l], ans[r]);
			}
		}else if( S[i] == '+' ){
			sf++;
		}else if( S[i] == '-' ){
			sf--;
		}else if( S[i] == '?' ){
			ans[now++] = 'A';
			sf = 0;
		}else{
			sf %= 26;
			char tmp = S[i] + sf;
			if( S[i] + sf > 'Z' ) tmp = 'A' + sf - ('Z' - S[i] + 1);
			if( S[i] + sf < 'A' ) tmp = 'Z' + sf + (S[i] - 'A' + 1);
			ans[now++] = tmp;
			sf = 0;
		}
	}
	ans[now] = '\0';
	cout << ans << endl;
}

int main(){
	while(cin>>S, S != "."){
		solve();
	}
	return 0;
}