#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<int, int> > > vec(600100);
string stre;
int IIt = 0;
int form_tree(int level) {
  int i, child;
  int intial = IIt;
  while (stre[IIt] != ',') {
    IIt++;
  }
  vec[level].push_back(make_pair(intial, IIt - intial));
  i = 0;
  char chili[100];
  IIt++;
  while (stre[IIt] != ',' && stre[IIt] != '\0') {
    chili[i++] = stre[IIt];
    IIt++;
  }
  if (IIt != stre.length()) IIt++;
  chili[i] = '\0';
  child = atoi(chili);
  for (i = 0; i < child; i++) {
    form_tree(level + 1);
  }
  return 0;
}
int main() {
  std::ios::sync_with_stdio(false);
  int i, j, maxi = 0;
  cin >> stre;
  form_tree(0);
  while (IIt != stre.length()) {
    form_tree(0);
  }
  while (vec[maxi].size() != 0) {
    maxi++;
  }
  cout << maxi << endl;
  for (i = 0; i < maxi; i++) {
    for (j = 0; j < vec[i].size(); j++) {
      cout << stre.substr(vec[i][j].first, vec[i][j].second) << " ";
    }
    cout << endl;
  }
}
