#include <bits/stdc++.h>
using namespace std;
const int64_t MOD = 1e9 + 7;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  string cw = "";
  int64_t cnum = 0;
  stack<int64_t> lev;
  int64_t d = 0;
  int64_t n = s.length();
  int64_t pnum = 0;
  vector<vector<string>> ans(n);
  int64_t f = 0;
  lev.push(1000000000);
  int64_t ml = 0;
  for (int64_t i = 0; i < n; i++) {
    if (s[i] == ',') {
      if (f) {
        int64_t kek = lev.top();
        while (kek == 0) {
          lev.pop();
          kek = lev.top();
          d--;
        }
        ans[d].push_back(cw);
        ml = max(ml, d);
        cw = "";
        lev.pop();
        kek--;
        lev.push(kek);
        if (cnum != 0) {
          d++;
          lev.push(cnum);
        }
      }
      f = 1 - f;
      cnum = 0;
    } else if (!f) {
      cw += s[i];
    } else if (f) {
      cnum *= 10;
      cnum += (s[i] - '0');
    }
  }
  int64_t kek = lev.top();
  while (kek == 0) {
    lev.pop();
    kek = lev.top();
    d--;
  }
  ans[d].push_back(cw);
  ml = max(ml, d);
  cw = "";
  lev.pop();
  kek--;
  lev.push(kek);
  if (cnum != 0) {
    d++;
    lev.push(cnum);
  }
  cout << ml + 1 << "\n";
  for (int64_t i = 0; i <= ml; i++) {
    for (string s : ans[i]) {
      cout << s << " ";
    }
    cout << "\n";
  }
  return 0;
}
