#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000010;
char s[maxn];
int gs[maxn];
vector<string> vs[maxn];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ;
  cin >> s;
  int n = strlen(s);
  gs[1] = maxn;
  int pg = 1, ps = 0;
  int ma = 1;
  while (ps < n) {
    string ss = "";
    while (s[ps] != ',') {
      ss += s[ps];
      ++ps;
    }
    ss += ' ';
    ++ps;
    int num = 0;
    while (s[ps] != ',' && s[ps] != '\0') {
      num = num * 10 + s[ps] - '0';
      ++ps;
    }
    ++ps;
    vs[pg].push_back(ss);
    --gs[pg];
    if (num) {
      ++pg;
      gs[pg] = num;
      ma = max(ma, pg);
    }
    while (gs[pg] == 0) --pg;
  }
  cout << ma << '\n';
  for (int j = 1; j <= ma; ++j) {
    for (int k = 0; k < vs[j].size(); ++k) cout << vs[j][k];
    cout << '\n';
  }
  cout << flush;
  return 0;
}
