#include <bits/stdc++.h>
using namespace std;
const int N = 1000100;
char c;
int ml, l, k, t, p;
string s;
stack<int> heap;
stack<int> heap2;
vector<string> v[N];
int main() {
  l = 0;
  ml = 0;
  s = "";
  while ((c = getchar()) != '\n') {
    if (c == ',') {
      while (!heap.empty()) {
        t = heap.top();
        heap.pop();
        if (t - 1 > 0) {
          heap.push(t - 1);
          break;
        } else {
          l = max(l - 1, 0);
        }
      }
      v[l].push_back(s);
      s = "";
      while (scanf("%c", &c) == 1) {
        if (c == ',' || (c - '0') < 0 || (c - '0') > 10) break;
        heap2.push(c - '0');
      }
      k = 0;
      p = 1;
      while (!heap2.empty()) {
        k += heap2.top() * p;
        heap2.pop();
        p *= 10;
      }
      if (k > 0) {
        heap.push(k + 1);
        l += 1;
        ml = max(ml, l);
      }
      if (c == ',')
        continue;
      else
        break;
    } else {
      s += c;
    }
  }
  cout << (ml + 1) << endl;
  int i;
  for (i = 0; i <= ml; ++i) {
    for (auto x : v[i]) {
      cout << x << " ";
    }
    cout << endl;
  }
  return 0;
}
