#include <bits/stdc++.h>
using namespace std;
vector<string> indx[1000005];
stack<int> st2;
int main() {
  string s;
  cin >> s;
  int mark = 0;
  int ended = 0;
  int mx = -1;
  string temp;
  for (int i = 0; s[i];) {
    if (s[i] == ',') {
      temp[temp.size()] = 0;
      indx[st2.size()].push_back(temp);
      mx = max(mx, (int)st2.size());
      mark = 0;
      int cnt = 0;
      i++;
      while (s[i] != ',' && s[i] != 0) {
        cnt = cnt * 10 + s[i] - '0';
        i++;
        if (s[i] == 0) {
          ended = 1;
        }
      }
      st2.push(cnt);
      int p = st2.top();
      while (!st2.empty() && st2.top() == 0) {
        st2.pop();
        if (!st2.empty()) {
          int p = st2.top();
          st2.pop();
          st2.push(p - 1);
        }
      }
      i++;
    }
    if (mark == 0) {
      temp.clear();
      temp.push_back(s[i]);
      mark = 1;
      i++;
    } else if (mark == 1) {
      temp.push_back(s[i]);
      i++;
    }
    if (ended == 1) break;
  }
  printf("%d\n", mx + 1);
  for (int i = 0; i <= mx; i++) {
    if (indx[i].size()) {
      for (int j = 0; j < indx[i].size(); j++) {
        cout << indx[i][j] << " ";
      }
      cout << endl;
    }
  }
}
