#include <bits/stdc++.h>
using namespace std;
string s;
vector<string> a[1000005];
int maxx = 0;
int dfs(int p, int lv) {
  maxx = max(maxx, lv);
  string rt;
  while (s[p] != ',') {
    rt += s[p];
    p++;
  }
  a[lv].push_back(rt);
  p++;
  int cnt = 0;
  while (s[p] != ',') {
    cnt = cnt * 10 + s[p] - '0';
    p++;
  }
  p++;
  for (int i = 0; i < cnt; i++) {
    p = dfs(p, lv + 1);
  }
  return p;
}
int main() {
  getline(cin, s);
  s += ',';
  int p = 0;
  while (p < int(s.length())) {
    p = dfs(p, 0);
  }
  cout << maxx + 1 << endl;
  for (int i = 0; !a[i].empty(); i++) {
    for (auto& t : a[i]) {
      cout << t << " ";
    }
    cout << endl;
  }
  return 0;
}
