#include <bits/stdc++.h>
using namespace std;
int p, level;
vector<vector<string>> v;
string s;
void sol() {
  while (p < s.size() && s[p] == ',') p++;
  if (v.size() < level + 1) v.push_back({});
  v[level].push_back("");
  for (; s[p] != ','; p++) v[level].back() += s[p];
  p++;
  int val;
  sscanf(s.c_str() + p, "%d", &val);
  while (p < s.size() && isdigit(s[p])) p++;
  level++;
  for (int i = 0; i < val; i++) sol();
  level--;
}
int main() {
  cin >> s;
  while (p < s.size()) sol();
  printf("%d\n", v.size());
  for (auto &vv : v) {
    for (string &str : vv) printf("%s ", str.c_str());
    printf("\n");
  }
}
