//
// Problem: Plus Minus Cipher
// Solution by: MORI Shingo
// O(n^2)
//
// implement 11min
// 
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const long double EPS = 1e-9;
static const long double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n;
string str;

string Cipher(int &pos);
string String(int &pos);
string Letter(int &pos);

string Cipher(int &pos) {
  string ret = String(pos);
  if (pos < n && str[pos] != ']') { ret += Cipher(pos); }
  return ret;
}

string String(int &pos) {
  assert(pos < n);
  string ret = "";
  if (str[pos] == '[') {
    pos++;
    ret = Cipher(pos);
    reverse(ret.begin(), ret.end());
    assert(str[pos] == ']');
    pos++;
  } else {
    ret = Letter(pos);
  }
  return ret;
}

string Letter(int &pos) {
  assert(pos < n);
  string ret = "";
  char c = str[pos];
  pos++;
  if (isalpha(c) || c == '?') {
    ret = c;
  } else {
    assert(c == '+' || c == '-');
    ret = Letter(pos);
    if (ret[0] != '?') {
      if (c == '+') { ret[0] += 1; }
      if (c == '-') { ret[0] -= 1; }
      if (ret[0] < 'A') { ret[0] += 26; }
      if (ret[0] > 'Z') { ret[0] -= 26; }
    }
  }
  return ret;
}

int main() {
  while (cin >> str && str[0] != '.') {
    n = str.size();
    int pos = 0;
    string ans = Cipher(pos);
    REP(i, n) {
      if (ans[i] == '?') { ans[i] = 'A'; }
    }
    cout << ans << endl;
  }
}
