#include <iostream>
#include <list>
#include <string>

using namespace std;

string processKeys(const string& keys) {
    list<char> text;
    auto cursor = text.begin();

    for (char key : keys) {
        if (key == '[') {
            cursor = text.begin();
        } else if (key == ']') {
            cursor = text.end();
        } else {
            text.insert(cursor, key);
        }
    }

    return string(text.begin(), text.end());
}

int main() {
        string keys;
        getline(cin, keys);
        cout << processKeys(keys) << endl;

    return 0;
}