#include <bits/stdc++.h>
using namespace std;
int ans;
vector<string> v[1000100];
int idx;
string str;
void go(int lvl, int cnt) {
  ans = max(ans, lvl);
  for (int i = 0; i < cnt; i++) {
    string tmp = "";
    while (idx < str.length() && str[idx] != ',') {
      tmp += str[idx++];
    }
    idx++;
    v[lvl].push_back(tmp);
    int n = 0;
    while (idx < str.length() && str[idx] != ',') {
      n = n * 10 + (str[idx++] - '0');
    }
    idx++;
    go(lvl + 1, n);
  }
}
int main() {
  cin >> str;
  while (idx < str.length()) go(1, 1);
  ans--;
  cout << ans << "\n";
  for (int i = 1; i <= ans; i++) {
    for (int j = 0; j < v[i].size(); j++) {
      cout << v[i][j] << " ";
    }
    cout << "\n";
  }
  return 0;
}
