#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
string name[maxn], s;
vector<int> G[maxn];
int tot, a[maxn], maxd, dep[maxn];
int dfs(int &p, int d) {
  maxd = max(maxd, d);
  int ret = ++tot;
  dep[ret] = d;
  while (s[p] != ',') {
    name[ret].push_back(s[p++]);
  }
  ++p;
  int son = 0;
  while (s[p] != ',') {
    son = son * 10 + s[p++] - '0';
  }
  ++p;
  for (int i = 0; i < son; ++i) G[ret].push_back(dfs(p, d + 1));
  return ret;
}
void bfs() {
  queue<int> que;
  cout << maxd;
  int t = 0;
  for (int i = 0; i < G[0].size(); ++i) que.push(G[0][i]);
  while (!que.empty()) {
    int p = que.front();
    que.pop();
    if (dep[p] != t) {
      ++t;
      cout << endl;
    } else
      cout << " ";
    cout << name[p];
    for (int i = 0; i < G[p].size(); ++i) que.push(G[p][i]);
  }
  cout << endl;
}
int main() {
  cin >> s;
  s.push_back(',');
  maxd = 0;
  int p = 0;
  while (p < s.size()) G[0].push_back(dfs(p, 1));
  bfs();
  return 0;
}
