#include <bits/stdc++.h>
using namespace std;
template <class T>
void Read(T &x) {
  char c;
  bool f(0);
  while (c = getchar(), c != EOF) {
    if (c == '-')
      f = 1;
    else if (c >= '0' && c <= '9') {
      x = c - '0';
      while (c = getchar(), c >= '0' && c <= '9') x = x * 10 + c - '0';
      ungetc(c, stdin);
      if (f) x = -x;
      return;
    }
  }
}
char s[1000000 + 10];
vector<string> a[1000000 + 10];
int n, mxd;
void read() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
}
bool myisalpha(char s) {
  return (s >= 'A' && s <= 'Z') || (s >= 'a' && s <= 'z');
}
int now;
void dfs(int i) {
  mxd = max(mxd, i);
  string t;
  while (!myisalpha(s[now]) && now <= n) now++;
  while (myisalpha(s[now])) t += s[now++];
  a[i].push_back(t);
  int num = 0;
  while (s[now] < '0' || s[now] > '9') now++;
  while (s[now] >= '0' && s[now] <= '9') num = num * 10 + s[now++] - '0';
  while (num--) dfs(i + 1);
}
void solve() {
  now = 1;
  int i;
  while (1) {
    while (!myisalpha(s[now]) && now <= n) now++;
    if (now > n) break;
    dfs(1);
  }
  cout << mxd << endl;
  for (i = 1; a[i].size(); i++) {
    for (auto j = a[i].begin(); j < a[i].end(); j++) cout << *j << ' ';
    cout << endl;
  }
}
int main() {
  read();
  solve();
}
