#include <bits/stdc++.h>
using namespace std;
char s[1000005];
int len, last, cnt, deep, pt;
int a[1000005], num[1000005], str[1000005];
int tot, point[1000005], nxt[1000005], v[1000005];
void add(int x, int y) {
  ++tot;
  nxt[tot] = point[x];
  point[x] = tot;
  v[tot] = y;
}
void dfs(int now, int dep) {
  deep = max(deep, dep + 1);
  add(dep + 1, now);
  while (num[now]) --num[now], dfs(++pt, dep + 1);
}
int main() {
  gets(s + 1);
  len = strlen(s + 1);
  last = 1;
  for (int i = 1; i <= len; ++i) {
    if (s[i] == ',' || i == len) {
      if (s[last] >= '0' && s[last] <= '9') {
        int x = 0;
        for (int j = last; j < i; ++j) x = x * 10 + s[j] - '0';
        num[cnt] = x;
      } else
        str[++cnt] = last;
      last = i + 1;
    }
  }
  pt = 0;
  while (pt < cnt) dfs(++pt, 0);
  printf("%d\n", deep);
  for (int i = 1; i <= deep; ++i) {
    a[0] = 0;
    for (int j = point[i]; j; j = nxt[j]) a[++a[0]] = v[j];
    for (int j = a[0]; j >= 1; --j) {
      int k = str[a[j]];
      while (s[k] != ',') putchar(s[k]), ++k;
      putchar(' ');
    }
    putchar('\n');
  }
}
