#include <bits/stdc++.h>
using namespace std;
vector<vector<string>> v;
void rec(int depth) {
  string s;
  getline(cin, s, ',');
  if (v.size() <= depth) {
    vector<string> tmp;
    v.push_back(tmp);
  }
  v[depth].push_back(s);
  int n;
  cin >> n;
  char c;
  cin >> c;
  for (int i = 0; i < n; i++) {
    rec(depth + 1);
  }
}
int main() {
  string s;
  vector<string> tmp;
  v.push_back(tmp);
  while (getline(cin, s, ',')) {
    v[0].push_back(s);
    int n;
    cin >> n;
    char c;
    cin >> c;
    for (int i = 0; i < n; i++) {
      rec(1);
    }
  }
  cout << v.size() << endl;
  for (int i = 0; i < v.size(); i++) {
    for (int j = 0; j < v[i].size(); j++) {
      cout << v[i][j] << ' ';
    }
    cout << endl;
  }
}
