#include <bits/stdc++.h>
using namespace std;
void solve() {
  string word;
  cin >> word;
  int n = word.size(), level = 0, i = 0;
  stack<int> s;
  map<int, vector<string>> ma;
  while (i < n) {
    string t = "";
    while (i < n and word[i] != ',') t += word[i++];
    i++;
    ma[level].push_back(t);
    t = "";
    while (i < n and word[i] != ',') t += word[i++];
    i++;
    int x = stoi(t);
    level++;
    if (!s.empty()) s.top()--;
    s.push(x);
    while (!s.empty() and s.top() == 0) {
      level--;
      s.pop();
    }
  }
  cout << ma.size() << endl;
  for (int i = 0; ma[i].size() > 0; i++) {
    for (int i1 = 0; i1 < ma[i].size(); i1++) cout << ma[i][i1] << " ";
    cout << endl;
  };
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
