#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>

using namespace std;

inline bool cheak(int x, int y, int xMax, int yMax){ return x >= 0 && y >= 0 && xMax > x && yMax > y; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }

typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef long long ll;
typedef unsigned long long ull;

#define For(i,a,b)	for(ll (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

const int dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, -1, 0, 1, -1, 1, -1, 1 };
const int mod = 1000000007;
const int INF = 1e9;

string s;
int t;

string cip();
string str();
char let();

string cip(){
	string ret;
	while (t < s.size() && s[t] != ']'){
		ret += str();
	}
	return ret;
}

string str(){
	string ret;
	if (s[t] == '['){
		t++; ret = cip(); t++;
		reverse(ret.begin(), ret.end());
		return ret;
	}
	else{
		return string(1,let());
	}
}

char let(){
	if (s[t] == '+'){
		t++; char c = let();
		if (c == 'Z')c = 'A';
		else c++;
		return c;
	}else
	if (s[t] == '-'){
		t++; char c = let();
		if (c == 'A')c = 'Z';
		else c--;
		return c;
	}
	else{
		t++;
		return s[t-1];
	}
}


string dfs(int n){

	if (n == s.size()){
		t = 0;
		return cip();
	}

	string ret(90,'Z'+1);

	if (s[n] == '?'){
		for (char c = 'A'; c <= 'Z'; c++){
			s[n] = c;
			ret = min(ret,dfs(n+1));
		}
		s[n] = '?';
	}
	else{
		ret = dfs(n + 1);
	}
	return ret;
}


int main(){

	while (cin >> s && s != "."){
		cout << dfs(0) << endl;
	}

	return 0;
}