#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100100;
struct bracket {
  char c;
  int idx;
  bracket(char c_ = '1', int idx_ = 0) {
    c = c_;
    idx = idx_;
  }
};
int n;
char s[MAXN];
stack<bracket> stck;
bool pos[MAXN];
void read() {
  scanf("%s", &s);
  n = (int)strlen(s);
}
void solve() {
  int i, best = 0, lb = 0, lr = 0;
  for (i = 0; i < n; ++i) {
    if (s[i] == '(' || s[i] == '[') {
      stck.push(bracket(s[i], i));
    } else if (!stck.empty()) {
      if (stck.top().c == '(' && s[i] == ')') {
        pos[stck.top().idx] = 1;
        pos[i] = 1;
        stck.pop();
      } else if (stck.top().c == '[' && s[i] == ']') {
        pos[stck.top().idx] = 1;
        pos[i] = 1;
        stck.pop();
      } else {
        while (!stck.empty()) {
          stck.pop();
        }
      }
    }
  }
  for (i = 0; i < n; ++i) {
    if (pos[i]) {
      int cnt = 0, l = i, r = i;
      while (pos[r]) {
        if (s[r] == '[') cnt++;
        r++;
      }
      if (best < cnt) {
        best = cnt;
        lb = l;
        lr = r - 1;
      }
      i = r - 1;
    }
  }
  printf("%d\n", best);
  if (best == 0) return;
  for (i = lb; i <= lr; ++i) {
    printf("%c", s[i]);
  }
  printf("\n");
}
int main() {
  read();
  solve();
  return 0;
}
