#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1000006;
int n, m;
pair<string, int> mess[MAX_N];
string s;
vector<string> level[MAX_N];
int maxl = 0;
int u;
int process(int x, int lv) {
  maxl = max(maxl, lv);
  level[lv].push_back(mess[x].first);
  u = x;
  for (int i = 1; i <= mess[x].second; i++) {
    u = process(u + 1, lv + 1);
  }
  return u;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> s;
  int count = 0;
  int i = 0;
  while (i < s.size()) {
    string ts = "";
    while (1) {
      if (s[i] == ',') break;
      ts += s[i];
      i++;
    }
    i++;
    string u = "";
    while (i < s.size()) {
      if (s[i] == ',' || s[i] == ' ') break;
      u += s[i];
      i++;
    }
    mess[count] = make_pair(ts, stod(u));
    count++;
    i++;
  }
  i = 0;
  while (i < count) i = process(i, 1) + 1;
  cout << maxl << endl;
  for (int i = 1; i <= maxl; i++) {
    for (int j = 0; j < level[i].size(); j++) cout << level[i][j] << " ";
    cout << endl;
  }
  return 0;
}
