#include <bits/stdc++.h>
using namespace std;
string s;
int p = 0;
int maxd;
vector<string> D[1000010];
bool is_digit(char c) { return ('0' <= c && c <= '9'); }
bool is_letter(char c) {
  return ('a' <= c && c <= 'z' || 'A' <= c && c <= 'Z');
}
void dfs(int d) {
  string comm;
  while (is_letter(s[p])) {
    comm += s[p];
    ++p;
  }
  maxd = max(maxd, d);
  D[d].push_back(comm);
  ++p;
  int sons = 0;
  while (is_digit(s[p])) {
    sons = sons * 10 + s[p] - '0';
    ++p;
  }
  ++p;
  for (int i = 0; i < sons; ++i) {
    dfs(d + 1);
  }
}
void solve() {
  cin >> s;
  while (p < s.length()) {
    dfs(0);
  }
  cout << maxd + 1 << "\n";
  for (int d = 0; d < maxd + 1; ++d) {
    for (auto& s : D[d]) {
      cout << s << " ";
    }
    cout << "\n";
  }
}
void reset() {
  for (int i = 0; i < maxd + 1; ++i) {
    D[i].clear();
  }
  maxd = 0;
  p = 0;
}
int main() {
  int k = 1;
  for (; k <= 1; ++k) {
    reset();
    solve();
  }
}
