#include <bits/stdc++.h>
using namespace std;
vector<string> p;
vector<vector<string> > ans;
vector<string> split(string p) {
  vector<string> ret;
  for (int i = 0; i < int(int((p).size())); i++) {
    int j = i;
    ret.push_back("");
    while (j < int((p).size()) && p[j] != ',') {
      ret.back().push_back(p[j++]);
    }
    i = j;
  }
  return ret;
}
int go(int i, int d = 0) {
  int t = stoi(p[i + 1]);
  if (d == int((ans).size())) {
    ans.push_back({});
  }
  ans[d].push_back(p[i]);
  int ret = i + 1;
  while (t--) {
    ret = go(ret + 1, d + 1);
  }
  return ret;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  string s;
  cin >> s;
  p = split(s);
  for (int i = -1; i + 1 < int((p).size()); i = go(i + 1))
    ;
  cout << int((ans).size()) << "\n";
  for (auto e : (ans)) {
    for (auto c : (e)) {
      cout << c << " ";
    }
    cout << "\n";
  }
  return 0;
}
