import std.stdio;
import std.c.stdio;
import std.uni;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;
 
void main() {
    string X;
    bool input() {
        X = readln.chomp;
        return X != ".";
    }
    void solve() {
        struct Parser {
            int index;
            char Letter() {
                //writeln("Letter");
                int C = 0;
                while (X[index] == '+' || X[index] == '-') {
                    C += (X[index] == '+' ? 1 : -1);
                    index++;
                }
                assert(X[index].isUpper || X[index] == '?');
                if (X[index] == '?') {
                    index++;
                    return 'A';
                } else {
                    char c = (X[index] - 'A' + 26 * 5 + C) % 26 + 'A';
                    index++;
                    return c;
                }
            }
            bool tryLetter() {
                return (X[index] == '+' || X[index] == '-' || X[index].isUpper || X[index] == '?');
            }
            string String() {
                //writeln("String");
                if (tryLetter) return [Letter()];
                assert(X[index] == '[');
                index++;
                char[] Ret = Cipher.dup;
                Ret.reverse;
                assert(X[index] == ']');
                index++;
                return cast(string)Ret;
            }
            string Cipher() {
                //writeln("Cipher");
                string Ret;
                while (index < X.length && X[index] != ']') {
                    Ret ~= String;
                }
                return Ret;
            }
        }
        Parser(0).Cipher.writeln;
    }
    while (input) solve;
}