#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9 + 5;
const int mod = (int)1e9 + 7;
const long long INF = (long long)4e18;
string second, t;
string w[1000010];
int N;
int n;
int mx;
vector<int> l[1000010];
int pos;
inline int Int() {
  int res = 0;
  for (int i = 0; i < (int)((t).size()); ++i) res = res * 10 + t[i] - '0';
  return res;
}
inline int getText() {
  t = "";
  while (pos < n && second[pos] != ',') t += second[pos++];
  if (pos < n) pos++;
  if (t == "") return 0;
  return 1;
}
void dfs(int d) {
  getText();
  l[d].push_back(N);
  mx = max(mx, d);
  int children = Int();
  for (int i = 0; i < children; ++i) {
    getText();
    w[++N] = t;
    dfs(d + 1);
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> second;
  n = (int)((second).size());
  while (getText()) {
    w[++N] = t;
    dfs(1);
  }
  cout << mx << endl;
  for (int i = 1; i <= mx; ++i) {
    for (int j = 0; j < (int)((l[i]).size()); ++j) {
      cout << w[l[i][j]] << " ";
    }
    cout << "\n";
  }
  return 0;
}
