#include <iostream>
#include <algorithm>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;

char letter();
string str();
string chipher();

string S;
int p;

char letter() {
  char ret;
  if(S[p] == '+') {
    p++;
    ret = letter();
    if('A' <= ret && ret <= 'Z') ret = ((ret - 'A') + 1) % 26 + 'A';
  } else if(S[p] == '-') {
    p++;
    ret = letter();
    if('A' <= ret && ret <= 'Z') ret = ((ret - 'A') + 25) % 26 + 'A';
  } else {
    ret = S[p++];
  }
  return ret;
}

string str() {
  string ret = "";
  if(S[p] == '[') {
    p++;
    ret = chipher();
    reverse(ret.begin(), ret.end());
    p++;
  } else {
    ret += letter();
  }
  return ret;
}

string chipher() {
  string ret = "";
  while(p < S.length() && S[p] != ']') ret += str();
  return ret;
}

int main(void) {
  while(cin >> S, S != ".") {
    p = 0;
    string ans = chipher();
    REP(i, 0, S.length()) if(ans[i] == '?') ans[i] = 'A';
    cout << ans << endl;
  }
}