#include <bits/stdc++.h>
using namespace std;
vector<string> out[1000005];
char s[1000005];
int d;
int parse(int p, int l) {
  string buf = "";
  d = max(d, l);
  for (; s[p] != ','; p++) buf += s[p];
  p++;
  int v = 0;
  for (; s[p] != ',' and s[p]; p++) v = v * 10 + s[p] - '0';
  p++;
  out[l].push_back(buf);
  while (v--) p = parse(p, l + 1);
  return p;
}
int main() {
  scanf("%s", s);
  int p = 0;
  while (s[p]) p = parse(p, 0);
  printf("%d\n", d + 1);
  for (int i = 0; i <= d; i++) {
    for (int j = 0; j < out[i].size(); j++) cout << out[i][j] << ' ';
    cout << endl;
  }
}
