#include <bits/stdc++.h>
using namespace std;
map<int, vector<string> > mp;
string s;
int n, pos = 0;
;
void dfs(int lvl) {
  int j = pos;
  while (s[j] != ',') j++;
  mp[lvl].push_back(s.substr(pos, j - pos));
  pos = j + 1;
  j++;
  while (s[j] != ',') j++;
  int ct = stoi(s.substr(pos, j - pos));
  pos = j + 1;
  for (int i = 1; i <= ct; i++) dfs(lvl + 1);
}
int main() {
  cin >> s;
  s += ',';
  n = s.length();
  while (pos < n) dfs(1);
  cout << mp.size() << "\n";
  for (auto it = mp.begin(); it != mp.end(); it++) {
    vector<string> vec = (*it).second;
    for (string str : vec) cout << str << " ";
    cout << "\n";
  }
}
