#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
const int N = 1000087;
const int inf = 2e9 + 87;
int n, mx, depth[N];
vector<int> bal;
vector<string> v, ans[N];
inline int turn(string s) {
  int ret = 0, pw = 1;
  reverse(s.begin(), s.end());
  for (char c : s) ret += pw * (c - '0'), pw *= 10;
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string raw;
  cin >> raw;
  raw += ",";
  int idx = 0;
  string cur = "";
  for (char c : raw) {
    if (c == ',') {
      if (idx & 1)
        bal.emplace_back(turn(cur));
      else
        v.emplace_back(cur);
      cur = "";
      idx++;
    } else
      cur += c;
  }
  n = v.size();
  stack<int> stk;
  for (int i = 0; i < n; ++i) {
    if (stk.empty()) {
      stk.emplace(i);
      depth[i] = 1;
    } else {
      depth[i] = depth[stk.top()] + 1;
      stk.emplace(i);
    }
    while (!stk.empty() and bal[stk.top()] == 0) stk.pop();
    if (!stk.empty()) bal[stk.top()]--;
  }
  for (int i = 0; i < n; ++i) {
    mx = max(mx, depth[i]);
    ans[depth[i]].emplace_back(v[i]);
  }
  cout << mx << "\n";
  for (int i = 1; i <= mx; ++i) {
    for (auto u : ans[i]) cout << u << " ";
    cout << "\n";
  }
  return 0;
}
