#include <bits/stdc++.h>
using namespace std;
inline long long getnum() {
  char c = getchar();
  long long num, sign = 1;
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') sign = -1;
  for (num = 0; c >= '0' && c <= '9';) {
    c -= '0';
    num = num * 10 + c;
    c = getchar();
  }
  return num * sign;
}
vector<string> V[1000003];
string S;
int mx = 0;
int go(int st, int lvl) {
  mx = max(lvl, mx);
  string T;
  int r = st;
  while (S[r] != ',') T += S[r], r++;
  V[lvl].push_back(T);
  r++;
  int x = 0;
  while (S[r] != ',') x = x * 10 + (S[r] - '0'), r++;
  r++;
  while (x--) {
    r = go(r, lvl + 1);
  }
  return r;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> S;
  S += ',';
  for (int i = 0; i < S.length() - 1;) {
    i = go(i, 1);
  }
  cout << mx << '\n';
  for (int i = 1; i <= mx; i++) {
    for (int j = 0; j < V[i].size(); j++) cout << V[i][j] << ' ';
    cout << '\n';
  }
}
