#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:66777216")
using namespace std;
map<char, int> mp;
vector<pair<string, int>> lex;
vector<string> lvl[1000001];
int lex_p = -1;
int max_l = 0;
void rec(int l, int cnt) {
  if (l > max_l) max_l = l;
  lvl[l].push_back(lex[lex_p].first);
  for (int i = 0; i < cnt; i++) {
    lex_p++;
    rec(l + 1, lex[lex_p].second);
  }
}
int main() {
  string s;
  cin >> s;
  int lex_cnt = 0;
  string cur_lex = "";
  string str = "";
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == ',' || i == s.length() - 1) {
      lex_cnt++;
      if (lex_cnt % 2 == 0) {
        int val = 0;
        int mn = 1;
        for (int j = cur_lex.length() - 1; j >= 0; j--) {
          val += (cur_lex[j] - '0') * mn;
          mn *= 10;
        }
        lex.push_back(make_pair(str, val));
        str = "";
        cur_lex = "";
      } else {
        str = cur_lex;
        cur_lex = "";
      }
    } else
      cur_lex += s[i];
  }
  while (lex_p < int(lex.size()) - 1) {
    lex_p++;
    rec(0, lex[lex_p].second);
  }
  cout << max_l + 1 << endl;
  for (int i = 0; i < 1000001; i++) {
    for (int j = 0; j < lvl[i].size(); j++) cout << lvl[i][j] << ' ';
    if (lvl[i].size() > 0) cout << endl;
  }
}
