#include <bits/stdc++.h>
using namespace std;
int n, x, y, k = 0, o;
string ss[1000005];
string s, tmp;
int D[1000005];
vector<string> vt[1000005];
void convertstring(string txt) {
  ss[x] = txt;
  x++;
}
void convertint(int nm) {
  D[y] = nm;
  y++;
}
void dfs(int m) {
  o = max(o, m + 1);
  vt[m].push_back(ss[k]);
  int p = k;
  for (int i = 0; i < D[p]; i++) k++, dfs(m + 1);
}
int main() {
  cin >> s;
  s += ',';
  int s_size = s.size();
  for (int i = 0; i < s_size; i++) {
    int kop = 0;
    if (s[i] >= '0' && s[i] <= '9') {
      while (s[i] != ',') {
        kop = kop * 10 + (s[i] - '0');
        i++;
      }
      convertint(kop);
      continue;
    } else if (s[i] == ',') {
      if (tmp != "") convertstring(tmp);
      tmp = "";
    } else
      tmp += s[i];
  }
  int cnt = max(x, y);
  while (k != cnt) {
    dfs(0);
    k++;
  }
  cout << o << endl;
  for (int i = 0; i < o; i++) {
    bool tt = true;
    for (auto j : vt[i])
      if (tt)
        cout << j, tt = false;
      else
        cout << " " << j;
    cout << endl;
  }
}
