#include <bits/stdc++.h>
using namespace std;
string s;
vector<pair<int, int> > res[2222222];
int len = 0;
void dfs(int& i, int lvl) {
  len = max(len, lvl);
  if (i == ((int)(s).size())) return;
  int len = 0;
  while (s[i + len] != ',') len++;
  res[lvl].push_back(make_pair(i, len));
  i += len + 1;
  int k = 0;
  while (s[i] != ',') k = k * 10 + s[i++] - '0';
  i++;
  for (int j = 0; j < k; j++) {
    dfs(i, lvl + 1);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> s;
  s += ',';
  int i = 0;
  while (i < ((int)(s).size())) {
    dfs(i, 0);
  }
  cout << len + 1 << endl;
  for (int i = 0; i <= len; i++) {
    for (int j = 0; j < ((int)(res[i]).size()); j++) {
      cout << s.substr(res[i][j].first, res[i][j].second) << " ";
    }
    cout << endl;
  }
  return 0;
}
