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