#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
const int N = 1000005;
vector<pair<pair<int, int>, int> > vp;
char s[N];
int ccnum(int i, int j) {
  int k, num = 0;
  for (k = i; k <= j; k++) num = num * 10 + (s[k] - '0');
  return num;
}
int getnxt(int tp) {
  for (int i = tp;; i++)
    if (s[i] == ',') return i;
}
void init(int n) {
  for (int i = 1; i <= n;) {
    int j = getnxt(i), k = getnxt(j + 1);
    vp.push_back(make_pair(make_pair(i, j - 1), ccnum(j + 1, k - 1)));
    i = k + 1;
  }
}
int now, Mdep;
vector<int> prt[N];
void dfs(int x, int dep) {
  int i, chd = vp[x].second;
  prt[dep].push_back(x);
  Mdep = max(Mdep, dep);
  for (i = 1; i <= chd; i++) dfs(++now, dep + 1);
}
void PRT(int x) {
  int j = vp[x].first.first, k = vp[x].first.second;
  for (int i = j; i <= k; i++) putchar(s[i]);
}
int main() {
  int i, n, k, cnt = 0;
  scanf("%s", s + 1);
  n = strlen(s + 1);
  s[++n] = ',';
  init(n);
  int vps = vp.size();
  Mdep = 0;
  for (now = 0; now < vps; now++) dfs(now, 1);
  printf("%d\n", Mdep);
  for (i = 1; i <= Mdep; i++) {
    int j, sz = prt[i].size();
    if (sz) PRT(prt[i][0]);
    for (j = 1; j < sz; j++) {
      printf(" ");
      PRT(prt[i][j]);
    }
    puts("");
  }
  return 0;
}
