#include <bits/stdc++.h>
using namespace std;
int main() {
  int mera[100001];
  int snct[100001];
  string s;
  cin >> s;
  int len = s.length();
  stack<int> st;
  if (s[0] == '[') {
    snct[0] = 1;
  } else {
    snct[0] = 0;
  }
  for (int i = 1; i < len; i++) {
    snct[i] = snct[i - 1];
    if (s[i] == '[') {
      snct[i]++;
    }
  }
  for (int i = 0; i < len; i++) {
    mera[i] = -1;
    if (s[i] == '(' || s[i] == '[') {
      st.push(i);
    } else if (s[i] == ')') {
      if (!st.empty()) {
        int h = st.top();
        if (h != -1 && s[h] == '(') {
          mera[i] = h;
          st.pop();
        } else {
          st.push(-1);
        }
      }
    } else {
      if (!st.empty()) {
        int h = st.top();
        if (h != -1 && s[h] == '[') {
          mera[i] = h;
          st.pop();
        } else {
          st.push(-1);
        }
      }
    }
  }
  for (int i = 0; i < len; i++) {
    if (mera[i] != -1 && mera[i] > 0 && mera[mera[i] - 1] != -1) {
      mera[i] = mera[mera[i] - 1];
    }
  }
  int max = 0;
  int x = -1;
  for (int i = 0; i < len; i++) {
    if (mera[i] != -1) {
      int c = snct[i];
      if (mera[i] > 0) c -= snct[mera[i] - 1];
      if (c > max) {
        x = i;
        max = c;
      }
    }
  }
  cout << max << endl;
  if (max > 0) cout << s.substr(mera[x], x - mera[x] + 1);
  return 0;
}
