#include <bits/stdc++.h>
using namespace std;
int brute(int argc, char *argv[]) { return 0; }
int tests(int argc, char *argv[]) { return 0; }
string s;
string actual;
istringstream iss;
int depth = 0;
int pos = 0;
vector<pair<string, int> > inp;
map<int, vector<string> > v;
void recurse(int d) {
  if (pos >= inp.size()) return;
  depth = max(d, depth);
  string a;
  int b;
  a = inp[pos].first;
  b = inp[pos].second;
  v[d].push_back(a);
  ++pos;
  bool f = (b == 0);
  while (b--) {
    recurse(d + 1);
  }
  if (d == 1) {
    if (pos < inp.size()) recurse(d);
  }
}
void parse() {
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == ',') s[i] = ' ';
  }
  istringstream is(s);
  string b;
  int a;
  while (is >> b >> a) {
    inp.push_back(make_pair(b, a));
  }
  recurse(1);
}
int _main(int argc, char *argv[]) {
  cin >> actual;
  s = actual;
  parse();
  cout << depth << endl;
  for (int i = 1; i <= depth; ++i) {
    for (int j = 0; j < v[i].size(); ++j) {
      if (j > 0) printf(" ");
      printf("%s", v[i][j].c_str());
    }
    printf("\n");
  }
  return 0;
}
int main(int argc, char *argv[]) {
  if (argc >= 2 && argv[1][0] == '1') {
    brute(argc, argv);
  } else if (argc >= 2 && argv[1][0] == '2') {
    tests(argc, argv);
  } else {
    _main(argc, argv);
  }
  return 0;
}
