#include <bits/stdc++.h>
using namespace std;
int mx, l;
string s, ans[1000002];
int f[1000002];
int main() {
  cin >> s;
  l = mx = 1;
  f[0] = 2e9;
  for (int i = 0; i < s.size(); i++) {
    while (!f[l - 1]--) l--;
    if (l > mx) mx = l;
    while (s[i] != ',') {
      ans[l] += s[i];
      i++;
    }
    ans[l] += ' ';
    f[l] = 0;
    i++;
    for (; i < s.size() && s[i] != ','; i++) f[l] = f[l] * 10 + s[i] - '0';
    l++;
  }
  cout << mx << "\n";
  for (int i = 1; i <= mx; i++) cout << ans[i] << "\n";
  return 0;
}
