#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 1, 0, -1, -1, -1, 1, 1};
int dy[] = {1, 0, -1, 0, 1, -1, 1, -1};
vector<string> ans[500010];
int mx = 0;
vector<pair<string, int> > v;
int id = 0;
void f(int depth) {
  int idx = id;
  mx = max(depth, mx);
  ans[depth].push_back(v[idx].first);
  while (v[idx].second--) {
    id++;
    f(depth + 1);
  }
  if (depth == 1 && id + 1 < v.size()) {
    id++;
    f(depth);
  }
}
int main() {
  string s;
  char c;
  cin >> s;
  stringstream ss(s);
  s = "";
  while (ss >> c) {
    if (c == ',') {
      int x;
      ss >> x;
      v.push_back(make_pair(s, x));
      s = "";
      ss >> c;
    } else {
      s += c;
    }
  }
  f(1);
  cout << mx << endl;
  for (int i = 1; i <= mx; i++) {
    for (int j = 0; j < ans[i].size(); j++) cout << ans[i][j] << " ";
    cout << endl;
  }
  return 0;
}
