#include <bits/stdc++.h>
using namespace std;
stringstream y;
string s;
vector<string> z[1000005];
int l, u = 0;
void r(int d, int x) {
  while (x--) u = max(u, d), y >> s >> l, z[d].push_back(s), r(d + 1, l);
}
int main() {
  ios::sync_with_stdio(false);
  cin >> s;
  for (int i = 0; i < s.size(); i++)
    if (s[i] == ',') s[i] = ' ';
  y.str(s);
  while (y >> s >> l) z[0].push_back(s), r(1, l);
  cout << ++u << endl;
  for (l = 0; l < u; l++) {
    for (int j = 0; j < z[l].size(); j++) {
      string v = z[l][j];
      cout << v << " ";
    }
    cout << endl;
  }
}
