#include <bits/stdc++.h>
using namespace std;
map<int, vector<string> > mapi;
vector<pair<string, int> > v;
int lev = 0;
void splito(string str) {
  int n = str.size();
  string neww1 = "", neww2 = "";
  bool sw = true;
  int p = 0;
  while (p < n) {
    if (str[p] == ',') {
      p++;
      while (p < n && str[p] != ',') {
        neww2.push_back(str[p]);
        p++;
      }
      int y = stoi(neww2);
      v.push_back(make_pair(neww1, y));
      neww1 = neww2 = "";
      p++;
    } else {
      neww1.push_back(str[p]);
      p++;
    }
  }
}
int maximow = 0;
void dfs(int L) {
  maximow = max(maximow, L);
  mapi[L].push_back(v[lev].first);
  int u = v[lev].second;
  lev++;
  for (int i = 0; i < u; i++) {
    dfs(L + 1);
  }
}
int main() {
  int n;
  string str, a;
  getline(cin, str);
  splito(str);
  lev = 0;
  n = v.size();
  while (lev < n) {
    mapi[0].push_back(v[lev].first);
    int X = v[lev].second;
    lev++;
    for (int i = 0; i < X; i++) {
      dfs(1);
    }
  }
  cout << (maximow + 1) << "\n";
  for (int i = 0; i <= maximow; i++) {
    for (int j = 0; j < mapi[i].size(); j++) {
      cout << mapi[i][j] << " ";
    }
    cout << "\n";
  }
  return 0;
}
