#include <bits/stdc++.h>
using namespace std;
int i, h, j, w;
string s, t, v;
pair<string, int> k;
stack<int> p;
vector<pair<string, int>> a;
int main() {
  cin >> s;
  v = s;
  t = s;
  for (i = 0; i < s.size(); i++)
    if (s[i] == '(' || s[i] == '[') p.push(i);
  while (!p.empty()) {
    j = p.top();
    if (s[j] == '(' && s[j + 1] == ')')
      v[j] = '0', v[v.find(')', j)] = '0', s.erase(j, 2);
    if (s[j] == '[' && s[j + 1] == ']')
      v[j] = '0', v[v.find(']', j)] = '0', s.erase(j, 2);
    p.pop();
  }
  for (i = 0; i < v.size(); i++) {
    if (v[i] == '0') {
      k.first += t[i];
      if (t[i] == '[') k.second++;
    }
    if (v[i] != '0' && k.first.size() || i == v.size() - 1 && k.first.size())
      a.push_back(k), k.first.clear(), h = max(h, k.second), k.second = 0;
  }
  if (!h)
    cout << 0;
  else if (!a.size())
    cout << k.second << endl << k.first;
  else {
    for (i = 0; i < a.size(); i++)
      if (a[i].second == h) {
        cout << h << endl << a[i].first;
        break;
      }
  }
}
