#include <bits/stdc++.h>
using namespace std;
const int N = 2000005;
const int inf = 1e9 + 7;
inline void read(int &x) {
  x = 0;
  char ch = getchar();
  while (ch < '0') ch = getchar();
  while (ch >= '0') {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
}
char s[N];
string ot;
string ans[N];
int to[N], head[N], nxt[N], e, dep[N], vt[N];
pair<int, int> st[N];
int top;
string ap[N];
inline void init() {
  memset(head, -1, sizeof(head));
  e = 0;
}
int aaa;
void dfs(int x, int d) {
  dep[x] = d;
  aaa = max(aaa, d);
  for (int i = head[x]; i + 1; i = nxt[i]) dfs(to[i], d + 1);
}
inline void add_edge(int x, int y) {
  to[e] = y;
  nxt[e] = head[x];
  head[x] = e++;
}
int main() {
  scanf("%s", s);
  init();
  ios::sync_with_stdio(false);
  int len = strlen(s);
  int n = 0;
  for (int i = (0); i <= (len - 1); i++) {
    int j = i;
    while (s[j] != ',') j++;
    n++;
    ans[n] = "";
    for (int k = (i); k <= (j - 1); k++) ans[n] += s[k];
    j++;
    int rp = 0;
    while (s[j] != ',' && j < len) {
      rp = rp * 10 + s[j] - '0';
      j++;
    }
    if (top) {
      st[top].first--;
      add_edge(st[top].second, n);
      vt[n] = 1;
      if (!st[top].first) top--;
    }
    if (rp) st[++top] = make_pair(rp, n);
    i = j;
  }
  for (int i = (1); i <= (n); i++)
    if (!vt[i]) dfs(i, 1);
  for (int i = (1); i <= (n); i++) {
    ap[dep[i]] += " ";
    ap[dep[i]] += ans[i];
  }
  cout << aaa << endl;
  for (int i = (1); i <= (aaa); i++) {
    int lp = ap[i].length();
    ot = "";
    for (int j = (1); j <= (lp - 1); j++) ot += ap[i][j];
    cout << ot << endl;
  }
  return 0;
}
