#include <bits/stdc++.h>
using namespace std;
string s;
int ind;
vector<vector<string>> dpt;
int max_depth;
int pow10(int a) {
  int ans = 1;
  for (int i = 0; i < a; i++) ans *= 10;
  return ans;
}
int readnum() {
  string curr = "";
  while (s[ind] >= '0' && s[ind] <= '9') {
    curr += s[ind];
    ind++;
  }
  ind += 1;
  reverse(curr.begin(), curr.end());
  int ans = 0;
  for (int i = 0; i < curr.size(); i++) ans += (curr[i] - '0') * pow10(i);
  return ans;
}
void read(int depth) {
  string curr = "";
  if (depth > max_depth) max_depth = depth;
  while (s[ind] != ',') {
    curr += s[ind];
    ind++;
  }
  ind++;
  dpt[depth].push_back(curr);
  int count = readnum();
  for (int i = 0; i < count; i++) read(depth + 1);
}
int main() {
  cin >> s;
  dpt.resize(1000000);
  while (ind < s.size()) read(1);
  cout << max_depth << endl;
  for (int i = 1; i <= max_depth; i++) {
    for (auto c : dpt[i]) cout << c << " ";
    cout << endl;
  }
  return 0;
}
