#include <bits/stdc++.h>
using namespace std;
string s;
int n;
vector<string> ans[500005];
int mx = 0;
string cur;
int pos;
int getNum(string &s) {
  istringstream iss(s);
  int x;
  iss >> x;
  return x;
}
void solve(int dep) {
  mx = max(mx, dep);
  cur.clear();
  while (pos < n && s[pos] != ',') {
    cur += s[pos];
    ++pos;
  }
  ans[dep].push_back(cur);
  ++pos;
  cur.clear();
  while (pos < n && s[pos] != ',') {
    cur += s[pos];
    ++pos;
  }
  int num = getNum(cur);
  for (int i = 0; i < num; i++) {
    ++pos;
    solve(dep + 1);
  }
}
int main() {
  cin >> s;
  n = s.size();
  pos = 0;
  while (pos < n) {
    solve(0);
    ++pos;
  }
  cout << mx + 1 << endl;
  for (int i = 0; i < mx + 1; i++) {
    bool firstTime = true;
    for (int j = 0; j < ans[i].size(); j++) {
      string s = ans[i][j];
      if (!firstTime) {
        cout << " ";
      }
      firstTime = false;
      cout << s << " ";
    }
    cout << endl;
  }
  return 0;
}
