#include <bits/stdc++.h>
using namespace std;
string str;
vector<char> G[500010];
stack<pair<int, int> > s;
int main() {
  ios::sync_with_stdio(0);
  cin >> str;
  string tmp = "";
  int now = 0;
  int maxx = 0;
  pair<int, int> cur = make_pair(0x3FFFFFFF, 0);
  int ans = 0;
  str = str + ",";
  for (int i = 0; i < str.length(); i++) {
    if (str[i] == ',') {
      if (now == 0) {
        maxx = 0;
      } else {
        G[cur.second].push_back(' ');
        if (maxx > 0) {
          s.push(cur);
          cur.first = maxx;
          cur.second++;
          ans = max(ans, cur.second);
        } else {
          cur.first--;
          while (cur.first == 0 && !s.empty()) {
            cur = s.top();
            s.pop();
            cur.first--;
          }
        }
      }
      now = now ^ 1;
      continue;
    }
    if (now == 0) {
      G[cur.second].push_back(str[i]);
    } else {
      maxx = maxx * 10 + str[i] - '0';
    }
  }
  cout << ans + 1 << endl;
  for (int i = 0; i <= ans; i++) {
    for (int j = 0; j < G[i].size(); j++) {
      cout << G[i][j];
    }
    cout << endl;
  }
  return 0;
}
