#include <bits/stdc++.h>
using namespace std;
const int MAX_LENGTH = 1000000, MAX_COMMENTS = (MAX_LENGTH + 1) / 4;
struct Comment {
  string comment;
  int successorsCount;
  Comment() {
    this->comment = "";
    this->successorsCount = 0;
  }
};
string s;
list<Comment> comments;
vector<list<Comment>> commentsAtDepth;
void parse() {
  for (int i = 0; i < s.length(); i++) {
    Comment comment;
    while (s[i] != ',') {
      comment.comment += s[i];
      i++;
    }
    i++;
    while (s[i] != ',') {
      comment.successorsCount *= 10;
      comment.successorsCount += s[i] - '0';
      i++;
    }
    comments.push_back(comment);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  cin >> s;
  s += ',';
  parse();
  stack<int> successors;
  successors.push(MAX_COMMENTS);
  int depth = 0;
  for (auto i : comments) {
    while (commentsAtDepth.size() < depth + 1) {
      commentsAtDepth.push_back(list<Comment>());
    }
    commentsAtDepth[depth].push_back(i);
    successors.top()--;
    successors.push(i.successorsCount);
    depth++;
    while (!successors.empty() && successors.top() == 0) {
      depth--;
      successors.pop();
    }
  }
  cout << commentsAtDepth.size() << '\n';
  for (auto depth : commentsAtDepth) {
    bool isFirst = true;
    for (auto i : depth) {
      if (!isFirst) {
        cout << ' ';
      }
      isFirst = false;
      cout << i.comment;
    }
    cout << '\n';
  }
  return 0;
}
