#include <iostream>
#include <vector>
#include <string>
#include <iterator>

using namespace std;
string a1 (string input)
{
    int i = 0;
    int c = 1;
    string a1_output = "";
    a1_output+=input.at(i++);
    while (c != 0)
    {
        if (input[i] == '[')
        {
            c++;
        }
        if (input[i] == ']')
        {
            c--;
        }
        if (c == 0) { return a1_output;} 
        else a1_output+=input.at(i);
        i++;
    }
    return a1_output;
}
std::vector<string> extract (string inp)
{
    std::vector<string> c_output {};
    for (int i = 0; i < inp.length(); i++)
    {
        if (inp.at(i) == '[')
        {
            c_output.push_back(a1(inp.substr(++i, inp.length())));
        }   
    }
    return c_output; //Ð¢Ð¾, Ñ‡Ñ‚Ð¾ Ð’Ð°Ð¼ Ð½Ð°Ð´Ð¾ - Ð²ÐµÐºÑ‚Ð¾Ñ€ Ñ Ð½ÑƒÐ¶Ð½Ñ‹Ð¼Ð¸ Ð´Ð°Ð½Ð½Ñ‹Ð¼Ð¸.
}

int main()
{
    std::vector<string> out;
    string input, temp;
    std::cin >> input;
    out = extract(input);
    std::copy(out.begin(), out.end(), std::ostream_iterator<string>(std::cout, "\n"));
    return 0;
}