#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 50;
int l, t, ans;
char s[N];
vector<string> dd[N];
bool check(char c) {
  return (!(c >= 'A' && c <= 'Z')) && (!(c >= 'a' && c <= 'z'));
}
void DFS(int d) {
  string nm;
  while (check(s[t])) t++;
  for (; t < l; t++)
    if (check(s[t]))
      break;
    else
      nm += s[t];
  int x = 0;
  while (s[t] > '9' || s[t] < '0') t++;
  while (s[t] >= '0' && s[t] <= '9') x = x * 10 + s[t] - '0', t++;
  dd[d].push_back(nm), ans = max(ans, d);
  for (int i = 1; i <= x; i++) DFS(d + 1);
}
void init() {
  cin >> s;
  l = strlen(s);
}
int main() {
  init();
  for (; t < l;) DFS(1);
  cout << ans << endl;
  for (int i = 1; i <= ans; i++) {
    for (int j = 0; j < dd[i].size(); j++) {
      cout << dd[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}
