#include <bits/stdc++.h>
using namespace std;
struct edge {
  int next;
  pair<int, int> to;
} e[1000005 * 2];
int head[1000005], tot[1000005], ecnt, top, len, p = 1;
char s[1000005];
void add(int x, pair<int, int> to) {
  e[++ecnt].to = to;
  e[ecnt].next = head[x];
  head[x] = ecnt;
}
pair<int, int> getWord() {
  while (s[p] == ',') p++;
  int st = p;
  while (s[p] != ',') p++;
  return make_pair(st, p - 1);
}
int getLen() {
  while (s[p] == ',') p++;
  int ret = 0;
  while (s[p] >= '0' && s[p] <= '9') {
    ret = ret * 10 + s[p] - '0';
    p++;
  }
  return ret;
}
void dfs(int Dep) {
  if (Dep > top) top = Dep;
  pair<int, int> hh = getWord();
  add(Dep, hh);
  int num = getLen();
  for (int i = 1; i <= num; i++) dfs(Dep + 1);
}
void output(pair<int, int> hh) {
  int st = hh.first, ed = hh.second;
  for (int i = st; i <= ed; i++) putchar(s[i]);
  putchar(' ');
}
stack<pair<int, int> > sta;
int main() {
  scanf("%s", s + 1);
  len = strlen(s + 1);
  while (p <= len) dfs(0);
  printf("%d\n", top + 1);
  for (int i = 0; i <= top; i++) {
    for (int now = head[i]; now; now = e[now].next) sta.push(e[now].to);
    while (!sta.empty()) output(sta.top()), sta.pop();
    putchar('\n');
  }
  return 0;
}
