#include<bits/stdc++.h>
#define N 100
#define M 26
using namespace std;
string s;
int p,len;
  
string bnf(){
  string res;
  int c=0;
  while(p!=len){
    char t=s[p];
    if(t=='+')p++,c++;
    if(t=='-')p++,c--;
    if('A'<=t&&t<='Z')
      res+=((s[p++]+c+M*N)-'A')%M+'A',c=0;
    if(t=='?')res+=s[p++],c=0;
    if(t=='[')p++,res+=bnf();
    if(t==']'){
      p++;
      reverse(res.begin(),res.end());
      break;
    }
  }  
  return res;
}
  
int main(){
  while(1){
    cin>>s;
    if(s==".")break;
    len=s.size();
    p=0;
    string ans=bnf();
    for(int i=0;i<(int)ans.size();i++)
      if(ans[i]=='?')ans[i]='A';
    cout<<ans<<endl;
  }
  return 0;
}