#include <bits/stdc++.h>
using namespace std;
char c;
int cnt;
vector<string> v[1000001];
void add(int k) {
  cnt = max(k, cnt);
  string s;
  int n;
  if (k == 1) s += c;
  while ((c = getchar()) != ',') s += c;
  cin >> n;
  getchar();
  v[k].push_back(s);
  for (int i = 1; i <= n; i++) {
    add(k + 1);
  }
}
int main() {
  while (cin >> c) {
    add(1);
  }
  cout << cnt << "\n";
  for (int i = 1; i <= cnt; i++) {
    for (int j = 0; j < v[i].size(); j++) cout << v[i][j] << " ";
    cout << "\n";
  }
  return 0;
}
