#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const int maxD = 1000010;
vector<string> lev[maxD];
int cpos = 0;
string readS(const string& s) {
  string ret = "";
  while ((s[cpos] - 'a' >= 0 && s[cpos] - 'z' <= 0) ||
         (s[cpos] - 'A' >= 0 && s[cpos] - 'Z' <= 0)) {
    ret += s[cpos];
    ++cpos;
  }
  ++cpos;
  return ret;
}
int readNum(const string& s) {
  int num = 0;
  while (s[cpos] >= '0' && s[cpos] <= '9') {
    num *= 10;
    num += (s[cpos] - '0');
    ++cpos;
  }
  ++cpos;
  return num;
}
int mlevel = -1;
void parse(const string& s, int level, int have = -1) {
  if (have == -1) {
    while (cpos < s.size()) {
      string cur = readS(s);
      lev[level].push_back(cur);
      mlevel = max(mlevel, level);
      int nhave = readNum(s);
      parse(s, level + 1, nhave);
    }
  } else {
    for (int i = 0; i < have; ++i) {
      string cur = readS(s);
      lev[level].push_back(cur);
      mlevel = max(mlevel, level);
      int nhave = readNum(s);
      parse(s, level + 1, nhave);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  string s;
  cin >> s;
  parse(s, 0);
  cout << mlevel + 1 << endl;
  for (int i = 0; i <= mlevel; ++i) {
    for (int j = 0; j < lev[i].size(); ++j) {
      cout << lev[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}
