#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 * 1000 + 17;
int n, i, mx;
string s;
vector<string> v[MAXN];
void input(int lvl) {
  if (i >= n) return;
  string res, child;
  int j = i;
  res += s[j];
  while (s[j + 1] != ',') j++, res += s[j];
  v[lvl].push_back(res);
  i = j + 2;
  j = i;
  child += s[j];
  while (j + 1 < s.size() && s[j + 1] != ',') j++, child += s[j];
  int tmp = stoi(child);
  i = j + 2;
  for (int j = 0; j < tmp; j++) input(lvl + 1);
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> s;
  n = s.size();
  while (i < n) input(0);
  for (int i = 0; i < MAXN; i++)
    if (v[i].size()) mx = i + 1;
  cout << mx << endl;
  for (int i = 0; i < MAXN; i++) {
    if (!v[i].size()) continue;
    for (int j = 0; j < v[i].size() - 1; j++) cout << v[i][j] << " ";
    cout << v[i].back() << endl;
  }
  return 0;
}
