#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  int n = s.size();
  vector<int> st;
  st.push_back(n);
  map<int, vector<string>> res;
  int mxLevel = 1;
  int i = 0;
  while (i < n) {
    int j = i;
    while (j < n && s[j] != ',') j++;
    string t = s.substr(i, j - i);
    j++;
    i = j;
    while (j < n && s[j] != ',') j++;
    string num = s.substr(i, j - i);
    i = j + 1;
    int x = stoi(num);
    while (st.size() && st.back() == 0) st.pop_back();
    st.back()--;
    mxLevel = max(mxLevel, (int)st.size());
    res[st.size()].push_back(t);
    st.push_back(x);
  }
  cout << mxLevel << endl;
  for (int i = 1; i <= mxLevel; i++) {
    for (int j = 0; j < res[i].size(); j++) {
      cout << res[i][j] << " ";
    }
    cout << endl;
  }
}
