#include <bits/stdc++.h>
using namespace std;
const int ms = 1111111;
char str[ms];
int n;
int b[ms], e[ms];
int u[ms];
int v = 0;
int d = 0;
int to[ms], adj[ms], ant[ms];
int z = 0;
void add_edge(int a, int b) {
  to[z] = b;
  ant[z] = adj[a];
  adj[a] = z++;
}
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>
    PQ;
int buildt(int c, int lvl) {
  d = max(d, lvl);
  PQ.push(make_pair(lvl, v));
  u[v] = lvl;
  int mv = v;
  b[v++] = c;
  int i = c;
  while (str[i] != ',') i++;
  e[mv] = i;
  int j = i + 1;
  while (j < n && str[j] != ',') j++;
  int f = 0;
  for (int x = i + 1; x < j; ++x) f = f * 10 + str[x] - '0';
  int l = j + 1;
  for (int x = 0; x < f; ++x) {
    add_edge(mv, v);
    l = buildt(l, lvl + 1);
  }
  return l;
}
int main() {
  scanf("%s", str);
  n = strlen(str);
  memset(adj, -1, sizeof adj);
  z = 0;
  int i = 0;
  while (i < n) {
    i = buildt(i, 0);
  }
  printf("%d", d + 1);
  int cl = -1;
  while (!PQ.empty()) {
    int x = PQ.top().second;
    PQ.pop();
    if (u[x] == cl) {
      printf(" ");
    }
    if (u[x] != cl) {
      cl = u[x];
      puts("");
    }
    for (int i = b[x]; i < e[x]; ++i) printf("%c", str[i]);
  }
  puts("");
  return 0;
}
