#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
const int MOD = 1e9 + 7;
const int MAX = 1e7 + 5;
const ll INF = 1e18 + 1;
vector<vector<string> > levels(MAX);
vector<string> comments;
vector<int> children, visited(MAX, 0);
int mx = 0, n, c;
void dfs(int cur, int cnt) {
  visited[cur] = 1;
  mx = max(mx, cnt);
  levels[cnt].emplace_back(comments[cur]);
  int l = children[cur];
  int done = 0;
  for (int j = cur + 1; j < n && done < l; j++) {
    if (visited[j]) continue;
    done++;
    dfs(j, cnt + 1);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s, x;
  cin >> s;
  replace(s.begin(), s.end(), ',', ' ');
  stringstream _s(s);
  while (true) {
    _s >> x;
    if (!_s) break;
    _s >> c;
    comments.emplace_back(x);
    children.emplace_back(c);
  }
  n = comments.size();
  for (int i = 0; i < n; i++)
    if (!visited[i]) dfs(i, 0);
  cout << mx + 1 << "\n";
  for (int i = 0; i <= mx; i++) {
    for (auto str : levels[i]) cout << str << ' ';
    cout << "\n";
  }
  return 0;
}
