#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e6 + 11;
string s, ss, num;
vector<string> answer[N];
int lvl = 1, b[N], ct = 1, mx, mxi;
map<int, pair<string, string> > ARR;
bool used[N];
inline void dfs(int v, int dp) {
  mxi = max(mxi, dp);
  mx = max(v, mx);
  answer[dp].push_back(ARR[v].first);
  used[v] = 1;
  int nn = 0;
  for (int i = 0; i < ARR[v].second.size(); i++) {
    nn += ARR[v].second[i] - '0';
    nn *= 10;
  }
  nn /= 10;
  for (int i = 1; i <= nn; i++) {
    dfs(mx + 1, dp + 1);
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> s;
  for (int i = 0; i < s.size(); ++i) {
    ss = "";
    num = "";
    while ((s[i] >= 'a' && s[i] <= 'z') || (s[i] >= 'A' && s[i] <= 'Z')) {
      ss += s[i];
      ++i;
    }
    while (s[i] >= '0' && s[i] <= '9') {
      num += s[i];
      ++i;
    }
    if (ss.size() > 0) {
      ARR[ct].first = ss;
    }
    if (num.size() > 0) ARR[ct].second = num, ct++;
  }
  for (int i = 1; i <= ct; ++i) {
    if (!used[i]) {
      mx = 0;
      dfs(i, 1);
    }
  }
  cout << mxi << "\n";
  for (int i = 1;; ++i) {
    if (answer[i].size() == 0) break;
    for (int j = 0; j < answer[i].size(); ++j) cout << answer[i][j] << " ";
    cout << "\n";
  }
}
