#include <bits/stdc++.h>
using namespace std;
struct noc_ctype : public std::ctype<char> {
  noc_ctype();
  const std::ctype<char>::mask* make_table();
};
vector<vector<string>> buffer;
void read(int depth = 0) {
  if (buffer.size() <= depth) {
    buffer.emplace_back();
  }
  {
    string s;
    char dlim = ',';
    getline(cin, s, ',');
    buffer[depth].push_back(s);
  }
  int a;
  cin >> a;
  for (int i = 0; i < a; ++i) {
    cin.ignore();
    read(depth + 1);
  }
}
int main() {
  do read();
  while (cin.get() == ',');
  cout << buffer.size() << '\n';
  for (auto& b : buffer) {
    for (auto& c : b) cout << c << ' ';
    cout << '\n';
  }
}
noc_ctype::noc_ctype() : ctype(make_table(), false, 0) {}
const std::ctype<char>::mask* noc_ctype::make_table() {
  static bool first = true;
  static std::vector<mask> table(classic_table(), classic_table() + table_size);
  if (first) {
    table[','] |= std::ctype_base::space;
  }
  return table.data();
}
