#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
deque<pair<string, int>> a;
int mx;
vector<string> ans[N];
void solve(int l = 1) {
  if (a.empty()) return;
  auto cur = a.front();
  a.pop_front();
  mx = max(mx, l);
  ans[l].push_back(cur.first);
  for (int i = 0; i < cur.second; i++) {
    solve(l + 1);
  }
}
int main() {
  string s = "";
  char c;
  while ((c = getchar()) != EOF) {
    if (c != ',') {
      s += c;
    } else {
      int num = 0;
      char c;
      while ((c = getchar()) != EOF) {
        if (c == ',') break;
        num = num * 10 + c - '0';
      }
      a.push_back({s, num});
      s = "";
    }
  }
  while (!a.empty()) solve();
  printf("%d\n", mx);
  for (int i = 1; i <= mx; i++) {
    for (string s : ans[i]) {
      printf("%s ", s.c_str());
    }
    printf("\n");
  }
  return 0;
}
