#include <bits/stdc++.h>
#pragma GCC optimize(3, "Ofast", "inline")
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = LONG_LONG_MAX;
const int N = 1e6 + 50;
string str;
int son;
stringstream Stream;
vector<string> v[N];
void dfs(int depth) {
  string s;
  getline(Stream, str, ',');
  v[depth].push_back(str);
  getline(Stream, str, ',');
  int son = stoi(str);
  for (int i = 1; i <= son; i++) dfs(depth + 1);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  getline(cin, str);
  Stream << str;
  while (!Stream.eof()) dfs(1);
  int cur = 0;
  while (v[cur + 1].size()) cur++;
  cout << cur << endl;
  for (int i = 1; i <= cur; i++) {
    for (auto &ans : v[i]) cout << ans << " ";
    cout << endl;
  }
  return 0;
}
