#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
const int N = 1000005;
char s[N];
int n, m, p;
struct Node {
  string str;
  int d;
} a[N];
void dfs(int d) {
  string tmp = "";
  while (s[p] != ',') tmp += s[p++];
  ++p;
  int son = 0;
  while (s[p] != ',') {
    son = son * 10 + s[p] - '0';
    ++p;
  }
  ++p;
  a[++m].str = tmp;
  a[m].d = d;
  for (int i = 1; i <= son; ++i) dfs(d + 1);
}
vector<string> ans[N];
int main() {
  ;
  scanf("%s", s + 1);
  int n = strlen(s + 1);
  ++n;
  s[n] = ',';
  p = 1;
  m = 0;
  while (p <= n) dfs(1);
  int d = 0;
  for (int i = 1; i <= m; ++i) {
    d = max(d, a[i].d);
    ans[a[i].d].push_back(a[i].str);
  }
  printf("%d\n", d);
  for (int i = 1; i <= d; ++i) {
    int sz = ans[i].size();
    for (int j = 0; j < sz; ++j) cout << ans[i][j] << ' ';
    puts("");
  }
  return 0;
}
