#include <bits/stdc++.h>
using namespace std;
stringstream y;
string s;
map<int, list<string> > z;
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 (char& c : s) c = c ^ 44 ? c : 32;
  y.str(s);
  while (y >> s >> l) z[0].push_back(s), r(1, l);
  cout << ++u << endl;
  for (l = -1; l++ < u;) {
    for (string v : z[l]) cout << v << " ";
    puts("");
  }
  return 0;
}
