#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 28;
char str[100010];
int sum[100010];
vector<pair<char, int> > e;
int main() {
  scanf("%s", str + 1);
  int ans = 0, begin, end;
  e.push_back(make_pair('L', 0));
  sum[0] = 0;
  for (int i = 1; str[i]; i++) {
    if (str[i] == '[')
      sum[i] = sum[i - 1] + 1;
    else
      sum[i] = sum[i - 1];
  }
  for (int i = 1; str[i]; i++) {
    if (str[i] == '(' || str[i] == '[') {
      e.push_back(make_pair(str[i], i));
    } else {
      if ((e.back().first == '(' && str[i] == ')') ||
          (e.back().first == '[' && str[i] == ']')) {
        e.pop_back();
        if (ans < sum[i] - sum[e.back().second]) {
          ans = sum[i] - sum[e.back().second];
          begin = e.back().second;
          end = i;
        }
      } else
        e.push_back(make_pair(str[i], i));
    }
  }
  printf("%d\n", ans);
  if (ans) {
    for (int i = begin + 1; i <= end; i++) printf("%c", str[i]);
  }
}
