#include <bits/stdc++.h>
using namespace std;
vector<vector<string> > comment;
int ans = 0;
void solve(int lvl) {
  ans = max(ans, lvl);
  char c;
  string s = "";
  while (scanf("%c", &c) == 1) {
    if (c == ',') {
      comment[lvl].push_back(s);
      s = "";
      int n;
      scanf("%d,", &n);
      for (int i = 0; i < n; i++) solve(lvl + 1);
      return;
    } else {
      s += c;
    }
  }
}
int main() {
  comment.resize(400000);
  char c;
  string s = "";
  while (scanf("%c", &c) == 1) {
    if (c == ',') {
      comment[0].push_back(s);
      s = "";
      int n;
      scanf("%d,", &n);
      for (int i = 0; i < n; i++) solve(1);
    } else {
      s += c;
    }
  }
  cout << ans + 1 << endl;
  for (int i = 0; i <= ans; i++) {
    for (int j = 0; j < comment[i].size(); j++)
      cout << (string)comment[i][j] << ' ';
    cout << endl;
  }
  return 0;
}
