#include <bits/stdc++.h>
using namespace std;
vector<vector<string> > v(1);
string s;
int idx = 0;
void fun(int x, string s2, int level) {
  while (x != 0) {
    int x1 = 0;
    string s21;
    s21 = s.substr(idx, s.find(',', idx) - idx);
    idx = s.find(',', idx) + 1;
    while (idx != s.size() && s[idx] != ',') {
      x1 *= 10;
      x1 += (s[idx] - '0');
      idx++;
    }
    if (idx != s.size()) {
      idx++;
    }
    if (level == v.size()) {
      vector<string> v2;
      v.push_back(v2);
    }
    v[level].push_back(s21);
    fun(x1, s21, level + 1);
    x--;
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> s;
  while (idx != s.size()) {
    string s2 = s.substr(idx, s.find(',', idx) - idx);
    idx = s.find(',', idx) + 1;
    int x = 0;
    while (idx != s.size() && s[idx] != ',') {
      x *= 10;
      x += (s[idx] - '0');
      idx++;
    }
    if (idx != s.size()) {
      idx++;
    }
    v[0].push_back(s2);
    fun(x, s2, 1);
  }
  cout << v.size() << endl;
  for (int i = 0; i < v.size(); i++) {
    for (int j = 0; j < v[i].size(); j++) {
      cout << v[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}
