#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  vector<vector<string> > tree;
  stack<int> st;
  st.push(0);
  while (getline(cin, s, ',')) {
    string n;
    getline(cin, n, ',');
    int count = atoi(n.c_str());
    int level;
    if (st.empty()) {
      level = 0;
    } else {
      level = st.top();
      st.pop();
    }
    if (level == tree.size()) {
      vector<string> temp;
      tree.push_back(temp);
    }
    tree[level].push_back(s);
    for (int i = 0; i < count; i++) st.push(level + 1);
  }
  cout << tree.size() << endl;
  for (int i = 0; i < tree.size(); i++) {
    for (int j = 0; j < tree[i].size(); j++) {
      cout << tree[i][j] << " ";
    }
    cout << endl;
  }
}
