#include <bits/stdc++.h>
using namespace std;
const int N = 2000005;
const int inf = 1000000009;
int c, Len, Ans, id;
char String[N], s[N];
int D[N], num[N], n, Q[N], h, t, x;
vector<int> e[N];
vector<char> v[N];
void getstr(char *s, int &l) {
  l = 0;
  while (String[c] != ',' && c < Len) s[l++] = String[c], c++;
  c++;
  s[l] = 0;
  return;
}
void getdig(int &x) {
  x = 0;
  while (String[c] != ',' && c < Len) x = x * 10 + String[c] - 48, c++;
  c++;
  return;
}
void Dfs(int x, int y, int dep) {
  Ans = max(Ans, dep);
  D[x] = dep;
  for (int i = ((int)1); i <= ((int)y); i++) {
    getstr(s, n);
    id++;
    for (int i = ((int)0); i <= ((int)n - 1); i++) v[id].push_back(s[i]);
    e[x].push_back(id);
    getdig(num[id]);
    Dfs(id, num[id], dep + 1);
  }
}
void write(int x) {
  for (int i = ((int)0); i <= ((int)v[x].size() - 1); i++) putchar(v[x][i]);
  putchar(32);
  return;
}
int main() {
  scanf("%s", String);
  Len = strlen(String) - 1;
  while (c < Len) {
    getstr(s, n);
    id++;
    e[0].push_back(id);
    for (int i = ((int)0); i <= ((int)n - 1); i++) v[id].push_back(s[i]);
    getdig(num[id]);
    Dfs(id, num[id], 1);
  }
  printf("%d", Ans);
  Q[t = 1] = 0;
  h = 0;
  while (h < t) {
    x = Q[++h];
    if (D[x] != D[Q[h - 1]]) puts("");
    if (x != 0) write(x);
    for (int j = ((int)0); j <= ((int)e[x].size() - 1); j++) Q[++t] = e[x][j];
  }
  return 0;
}
