#include <bits/stdc++.h>
using namespace std;
const long long int inf = 0x3f3f3f3f3f3f3f3fll;
const int mx = 15000005;
vector<string> adj[2000005];
vector<bool> vis;
vector<pair<string, int>> pa;
int ind = 0, mxx = 0;
void dfs(int d, int ti) {
  mxx = max(mxx, d);
  adj[d].push_back(pa[ind].first);
  while (ti--) {
    ind++;
    if (ind < pa.size()) dfs(d + 1, pa[ind].second);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  std::istringstream is(s);
  std::string token;
  int now = 1;
  while (std::getline(is, token, ',')) {
    if (now) {
      pa.push_back({token, 0});
    } else {
      int val = 0;
      for (char c : token) {
        val = val * 10 + (c - '0');
      }
      pa.back().second = val;
    }
    now = now ^ 1;
  }
  vis.assign(pa.size() + 1, false);
  while (ind < pa.size()) {
    dfs(0, pa[ind].second);
    ind++;
  }
  int i = 0;
  cout << mxx + 1 << endl;
  while (100) {
    if (adj[i].size() == 0) break;
    for (string u : adj[i]) cout << u << " ";
    cout << endl;
    i++;
  }
  return 0;
}
