#include <bits/stdc++.h>
using namespace std;
vector<string> res[1000000];
int main() {
  bool f = true;
  int now = 0;
  vector<int> cnt;
  cnt.push_back(1000000);
  string S, str;
  cin >> S;
  S.push_back(',');
  for (char c : S) {
    if (c == ',') {
      if (f) {
        res[now].push_back(str);
      } else {
        int x = stoi(str);
        if (x) {
          cnt.push_back(x);
          now++;
        } else {
          cnt.back()--;
          while (cnt.back() == 0) {
            cnt.pop_back();
            cnt.back()--;
            now--;
          }
        }
      }
      str = "";
      f = f == false;
    } else {
      str.push_back(c);
    }
  }
  int id = 0;
  for (; !res[id].empty(); id++)
    ;
  cout << id << endl;
  for (int i = 0;; i++) {
    if (!res[i].empty()) {
      for (int j = 0; j + 1 < res[i].size(); j++) {
        cout << res[i][j] << ' ';
      }
      cout << res[i].back() << endl;
    } else {
      break;
    }
  }
  return 0;
}
