#include <bits/stdc++.h>
using namespace std;
string second;
int b[150000];
int main() {
  cin >> second;
  stack<pair<char, int> > st;
  for (int i = 0; i < second.size(); i++) {
    if (second[i] == '(' || second[i] == '[') {
      st.push(make_pair(second[i], i));
    } else {
      if (second[i] == ')') {
        if (st.size() && st.top().first == '(') {
          b[st.top().second] = 1;
          b[i] = 1;
          st.pop();
        } else {
          st.push(make_pair(second[i], i));
        }
      }
      if (second[i] == ']') {
        if (st.size() && st.top().first == '[') {
          b[st.top().second] = 1;
          b[i] = 1;
          st.pop();
        } else {
          st.push(make_pair(second[i], i));
        }
      }
    }
  }
  int mx = 0, col = 0;
  string ans = "", w;
  for (int i = 0; i <= second.size(); i++) {
    if (b[i]) {
      if (second[i] == '[') col++;
      w += second[i];
    } else {
      if (mx < col) {
        mx = col;
        ans = w;
      }
      w = "";
      col = 0;
    }
  }
  cout << mx << endl << ans;
  return 0;
}
