#include <bits/stdc++.h>
void parse(int size, std::string& input, int& pos, int depth, int& max_depth,
           std::vector<std::vector<std::string> >& comments) {
  if (size <= pos) {
    return;
  }
  if (depth > max_depth) {
    max_depth = depth;
    comments.push_back(std::vector<std::string>());
  }
  int end = pos;
  while (input[end++] != ',') {
  }
  comments[depth].push_back(input.substr(pos, end - pos - 1));
  pos = end;
  while (end < size && input[end++] != ',') {
  }
  if (end == size) {
    ++end;
  }
  int children = std::stoi(input.substr(pos, end - pos - 1));
  pos = end;
  for (int i = 0; i < children; ++i) {
    parse(size, input, pos, depth + 1, max_depth, comments);
  }
}
int main() {
  std::string input;
  std::cin >> input;
  std::vector<std::vector<std::string> > comments;
  int max_depth = -1, pos = 0, size = input.size();
  while (pos < size) {
    parse(size, input, pos, 0, max_depth, comments);
  }
  std::cout << max_depth + 1 << std::endl;
  bool not_first;
  for (std::vector<std::string>& level : comments) {
    not_first = false;
    for (std::string& comment : level) {
      if (not_first) {
        std::cout << " ";
      } else {
        not_first = true;
      }
      std::cout << comment;
    }
    std::cout << std::endl;
  }
  return 0;
}
