#include <bits/stdc++.h>
using namespace std;
const int N3 = 1e3 + 15;
const int N4 = 1e4 + 15;
const int N5 = 1e5 + 15;
const int N6 = 1e6 + 15;
const int N7 = 1e7 + 15;
const int N8 = 1e8 + 15;
const int N9 = 1e9 + 15;
int n, ct, i = 1, pos, mxh;
string s, t, m;
map<int, int> used;
map<int, pair<string, string> > vec;
vector<string> ans[N6];
void dfs(int v, int h) {
  used[v] = 1;
  mxh = max(mxh, v);
  ct = max(ct, h);
  ans[h].push_back(vec[v].first);
  int x = atoi(vec[v].second.c_str());
  for (int i = 1; i <= x; ++i) {
    dfs(mxh + 1, h + 1);
  }
}
int main() {
  cin >> s;
  n = s.size();
  while (pos < n) {
    t = "";
    m = "";
    while (s[pos] != ',' && pos < n) t += s[pos], ++pos;
    ++pos;
    while (s[pos] != ',' && pos < n) m += s[pos], ++pos;
    ++pos;
    if (t.size() > 0) {
      vec[i].first = t;
    }
    if (m.size() > 0) vec[i].second = m, ++i;
  }
  for (int i = 1; i <= vec.size(); ++i) {
    if (!used[i]) mxh = 0, dfs(i, 1);
  }
  cout << ct << "\n";
  for (int i = 1;; ++i) {
    if (!ans[i].size()) break;
    for (int j = 0; j < ans[i].size(); ++j) cout << ans[i][j] << " ";
    cout << "\n";
  }
  return 0;
}
