#include <bits/stdc++.h>
int i, j, st[200000], score[200000], start[200000], t, max;
char s[200000];
int main() {
  scanf("%s", &s[1]);
  for (t = i = 1; s[i]; i++) {
    if (s[i] == '[')
      score[i] = score[i - 1] + 1;
    else
      score[i] = score[i - 1];
    if (s[i] == '(') {
      st[t] = 1;
      start[t++] = i;
    } else if (s[i] == '[') {
      st[t] = 2;
      start[t++] = i;
    } else if (s[i] == ')') {
      if (st[t - 1] == 1)
        t--;
      else {
        st[t] = 3;
        start[t++] = i;
      }
    } else if (s[i] == ']') {
      if (st[t - 1] == 2)
        t--;
      else {
        st[t] = 4;
        start[t++] = i;
      }
    }
  }
  start[t] = i;
  for (i = 0; i < t; i++) {
    if (start[i + 1] - start[i] > 1) {
      if (score[start[i + 1] - 1] - score[start[i]] > max) {
        max = score[start[i + 1] - 1] - score[start[i]];
        j = i;
      }
    }
  }
  printf("%d\n", max);
  if (max > 0)
    for (i = start[j] + 1; i < start[j + 1]; i++) printf("%c", s[i]);
  scanf(" ");
}
