#include <bits/stdc++.h>
using namespace std;
int mx;
void dfs(vector<vector<string>>& ord, int& depth,
         vector<pair<int, string>>& vec, int& idx) {
  if (idx < 0) return;
  depth++;
  mx = max(mx, depth);
  ord.resize(mx);
  int p = 0;
  ord[depth - 1].push_back(vec[idx].second);
  int nneed = vec[idx].first;
  idx--;
  if (idx < 0) return;
  for (int i = 0; i < nneed; i++) {
    int x = depth;
    dfs(ord, x, vec, idx);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  string tmp = "";
  auto conv = [&](string& s) {
    int res = 0;
    int tmp = 1;
    for (int i = s.size() - 1; i >= 0; i--) {
      res += (s[i] - '0') * tmp;
      tmp *= 10;
    }
    return res;
  };
  vector<pair<int, string>> vec;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == ',') {
      int p = 0;
      string tmp2 = "";
      for (int j = i + 1; j < s.size(); j++) {
        if (s[j] == ',') {
          int val = conv(tmp2);
          vec.emplace_back(val, tmp);
          p = j;
          break;
        } else {
          tmp2 += s[j];
        }
        if (j == s.size() - 1) {
          p = j;
          int val = conv(tmp2);
          vec.emplace_back(val, tmp);
        }
      }
      i = p;
      tmp = "";
    } else {
      tmp += s[i];
    }
  }
  reverse(vec.begin(), vec.end());
  int depth = 0;
  vector<vector<string>> ord;
  int idx = vec.size() - 1;
  while (idx >= 0) {
    depth = 0;
    dfs(ord, depth, vec, idx);
  }
  cout << mx << '\n';
  for (int i = 0; i < mx; i++) {
    for (int j = 0; j < ord[i].size(); j++) {
      cout << ord[i][j] << ' ';
    }
    cout << '\n';
  }
  return 0;
}
