#include <bits/stdc++.h>
using namespace std;
void pre() {
  freopen("a.inp", "r", stdin);
  freopen("a.out", "w", stdout);
}
const int N = 1e6 + 10;
string s;
vector<string> a[N];
int res = 0, d = 0;
int x[N];
int main() {
  char c;
  x[0] = 2 * N;
  while (c != '\n') {
    s = "";
    while ((c = getchar()) != ',') s += c;
    x[d++]--;
    scanf("%d", x + d);
    c = getchar();
    a[d].push_back(s);
    res = max(res, d);
    while (x[d] == 0) d--;
  }
  printf("%d\n", res);
  for (int i = (1); i <= (res); ++i) {
    for (int j = 0; j < a[i].size(); j++) printf("%s ", a[i][j].c_str());
    printf("\n");
  }
}
