#include <bits/stdc++.h>
using namespace std;
template <class T1>
void deb(T1 e) {
  cout << e << endl;
}
template <class T1, class T2>
void deb(T1 e1, T2 e2) {
  cout << e1 << " " << e2 << endl;
}
template <class T1, class T2, class T3>
void deb(T1 e1, T2 e2, T3 e3) {
  cout << e1 << " " << e2 << " " << e3 << endl;
}
template <class T1, class T2, class T3, class T4>
void deb(T1 e1, T2 e2, T3 e3, T4 e4) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << endl;
}
template <class T1, class T2, class T3, class T4, class T5>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << endl;
}
template <class T1, class T2, class T3, class T4, class T5, class T6>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5, T6 e6) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << " " << e6
       << endl;
}
template <class T>
T Abs(T x) {
  return x > 0 ? x : -x;
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
long long Pow(long long B, long long P) {
  long long R = 1;
  while (P > 0) {
    if (P % 2 == 1) R = (R * B);
    P /= 2;
    B = (B * B);
  }
  return R;
}
int BigMod(long long B, long long P, long long M) {
  long long R = 1;
  while (P > 0) {
    if (P % 2 == 1) {
      R = (R * B) % M;
    }
    P /= 2;
    B = (B * B) % M;
  }
  return (int)R;
}
string str;
struct data {
  int indx;
  char ch;
  data(char a, int b) {
    ch = a;
    indx = b;
  }
};
stack<data> s;
int sum[100500];
vector<pair<int, int> > v;
vector<pair<int, int> > v2;
int main(void) {
  cin >> str;
  for (int i = 0; i < (int)str.size(); i++) {
    if (s.empty()) {
      s.push(data(str[i], i));
      continue;
    }
    if (str[i] == ')') {
      if (s.top().ch == '(') {
        v2.push_back(make_pair(s.top().indx, i));
        s.pop();
        continue;
      } else {
        s.push(data(str[i], i));
        continue;
      }
    }
    if (str[i] == ']') {
      if (s.top().ch == '[') {
        v.push_back(make_pair(s.top().indx, i));
        s.pop();
        continue;
      } else {
        s.push(data(str[i], i));
        continue;
      }
    }
    s.push(data(str[i], i));
  }
  map<int, int> M;
  map<int, int> M2;
  for (int i = 0; i < (int)v.size(); i++) M[v[i].first] = v[i].second;
  for (int i = 0; i < (int)v2.size(); i++) M2[v2[i].first] = v2[i].second;
  stack<int> tmp;
  int mn = 0;
  for (int i = 0; i < (int)str.size(); i++) {
    if (M.find(i) == M.end() && M2.find(i) == M2.end() && i <= mn)
      sum[i] = ((i - 1 >= 0) ? sum[i - 1] : 0);
    else if (M.find(i) != M.end() || M2.find(i) != M2.end()) {
      if (M.find(i) != M.end())
        sum[i] = 1 + ((i - 1 >= 0) ? sum[i - 1] : 0);
      else
        sum[i] = ((i - 1 >= 0) ? sum[i - 1] : 0);
      mn = max(mn, M[i]);
      mn = max(mn, M2[i]);
    }
  }
  int best = 0;
  int left, right = -1;
  for (int i = 0; i < (int)str.size(); i++) best = max(best, sum[i]);
  map<int, int> rev;
  for (__typeof((M).begin()) it = (M.begin()); it != (M).end(); ++it)
    rev[it->second] = it->first;
  for (__typeof((M2).begin()) it = (M2.begin()); it != (M2).end(); ++it)
    rev[it->second] = it->first;
  int get_mn = (int)str.size() - 1;
  if (best) {
    for (int i = (int)str.size() - 1; i >= 0; i--) {
      if (sum[i] == best && right == -1) {
        right = i;
        get_mn = min(get_mn, rev[i]);
        continue;
      } else if (i >= get_mn || sum[i] != 0) {
        if (rev.find(i) != rev.end()) get_mn = min(get_mn, rev[i]);
        left = i;
        continue;
      } else if (sum[i] == 0 && right != -1)
        break;
    }
    deb(best);
    deb(str.substr(left, right - left + 1));
  } else {
    deb(best);
    if ((int)v2.size())
      deb(str.substr(v2[0].first, v2[0].second - v2[0].first + 1));
  }
  return 0;
}
