#include <bits/stdc++.h>
using namespace std;
string S;
map<int, vector<string>> ans;
void dfs(int dpt, int& i) {
  if (i == S.length()) return;
  string s = "";
  while (S[i] != ',') {
    s += S[i];
    i++;
  }
  i++;
  int n = 0;
  while (S[i] != ',') {
    n = n * 10 + (S[i] - '0');
    i++;
  }
  i++;
  ans[dpt].push_back(s);
  for (int j = 0; j < n; j++) dfs(dpt + 1, i);
}
int main() {
  cin >> S;
  S = S + ",";
  int i = 0;
  while (i != S.length()) dfs(0, i);
  int a = ans.size();
  printf("%d\n", a);
  for (auto p : ans) {
    for (int j = 0; j < p.second.size(); j++) {
      printf("%s", p.second[j].c_str());
      if (j != p.second.size() - 1) printf(" ");
    }
    printf("\n");
  }
}
