#include <bits/stdc++.h>
using namespace std;
string s;
int n, pos = 0, mh;
vector<string> vs;
vector<int> vc;
vector<string> ans[1000010];
void dfs(int h) {
  mh = max(mh, h);
  ans[h].push_back(vs[pos]);
  int ch = vc[pos];
  ++pos;
  for (int i = 0; i < ch; i++) {
    dfs(h + 1);
  }
}
void code() {
  cin >> s;
  n = (int)s.length();
  int flag = 0, last = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == ',') {
      string t = s.substr(last, i - last);
      if (flag == 0)
        vs.push_back(t);
      else
        vc.push_back(stoi(t));
      flag = 1 - flag;
      last = i + 1;
    }
  }
  vc.push_back(stoi(s.substr(last, n)));
  int tot = vs.size();
  while (pos < tot) dfs(0);
  cout << mh + 1 << '\n';
  for (int i = 0; i < mh + 1; i++) {
    for (string j : ans[i]) cout << j << " ";
    cout << '\n';
  }
}
int main() {
  int t = 1;
  while (t--) {
    code();
  }
}
