#include <bits/stdc++.h>
using namespace std;
string str;
int idx;
vector<vector<string> > ans;
pair<string, int> parse() {
  if (idx >= (int)str.size()) return make_pair("", -1);
  string res1;
  string res2;
  while (str[idx] != ',') {
    res1.push_back(str[idx]);
    idx++;
  }
  idx++;
  while (idx != str.size() && str[idx] != ',') {
    res2.push_back(str[idx]);
    idx++;
  }
  idx++;
  return make_pair(res1, stoi(res2));
}
void solve(int lvl) {
  if ((int)ans.size() <= lvl) ans.resize(ans.size() + 1);
  pair<string, int> p = parse();
  if (p.second != -1) {
    ans[lvl].push_back(p.first);
    for (int i = 0; i < p.second; i++) solve(lvl + 1);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> str;
  while (idx < str.size()) solve(0);
  cout << ans.size() << endl;
  for (vector<string>& vs : ans) {
    for (string& s : vs) cout << s << " ";
    cout << endl;
  }
  return 0;
}
