#include <bits/stdc++.h>
using namespace std;
vector<string> depth[1500000];
int w, k = 0;
int a = 0;
struct Test {
  string in;
  int child;
} P[1500000];
void compute(int dep) {
  w = max(w, dep);
  while (a != k) {
    int sz = 0;
    depth[dep].push_back(P[a].in);
    int ws = a;
    while (P[ws].child != sz) {
      a++;
      sz++;
      compute(dep + 1);
    }
    if (dep != 1) return;
    a++;
  }
  return;
}
int main() {
  string temp;
  int n;
  while (1) {
    char t;
    int num;
    getline(cin, temp, ',');
    scanf("%d", &num);
    scanf("%c", &t);
    P[k].in = temp;
    P[k].child = num;
    k++;
    if (t == '\n') break;
  }
  compute(1);
  printf("%d\n", w);
  for (int a = 1; a <= w; a++) {
    int sz = depth[a].size();
    for (int b = 0; b < sz; b++) {
      if (b != 0) printf(" ");
      cout << depth[a][b];
    }
    cout << endl;
  }
}
