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

using namespace std;

int main(){

	string sol[100];
	int nsol;
	string inp;
	int n;
	int c;

	while(1){

		cin>>inp;
		if(inp==".") break;

		n=0;
		c=0;
		for(int i=0;i<100;i++) sol[i]="";

		for(int i=0;i<inp.size();i++){
			switch(inp[i]){
			case '+':
				c++;
				break;
			case'-':
				c--;
				break;
			case'?':
				sol[n]+='A';
				c=0;
				break;
			case'[':
				n++;
				break;
			case']':
				reverse(sol[n].begin(),sol[n].end());
				sol[n-1]+=sol[n];
				sol[n]="";
				n--;
				break;
			default:
				nsol=(inp[i]-'A'+c)%26;
				if(nsol<0) nsol+=26;
				sol[n]+=nsol+'A';
				c=0;
				break;
			}
		}

		cout<<sol[0]<<endl;

	}

	return 0;
}