#include <bits/stdc++.h>
using namespace std;
vector<string> s_input;
string s;
void split() {
  long long l = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == ',') {
      s_input.push_back(s.substr(l, i - l));
      l = i + 1;
    }
  }
  s_input.push_back(s.substr(l));
}
int to_int(string ss) {
  int ans = 0;
  for (auto c : ss) {
    ans *= 10;
    ans += c - '0';
  }
  return ans;
}
int v = 0;
int j = 0;
vector<pair<int, int>> hs;
void build_g(int h) {
  if (j == s_input.size()) {
    return;
  }
  string text = s_input[j];
  int ch = to_int(s_input[j + 1]);
  j += 2;
  int cur_v = v;
  v++;
  hs.push_back({h, j - 2});
  for (int i = 0; i < ch; i++) {
    build_g(h + 1);
  }
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> s;
  split();
  while (j < s_input.size()) {
    build_g(1);
  }
  sort(hs.begin(), hs.end());
  cout << hs.back().first;
  int l = 0;
  for (auto p : hs) {
    if (l != p.first) {
      l++;
      cout << endl;
    }
    cout << s_input[p.second] << ' ';
  }
  return 0;
}
