#include <bits/stdc++.h>
using namespace std;
string input;
stringstream ss;
vector<string> a[1000001];
void dfs(int d) {
  string s;
  getline(ss, s, ',');
  a[d].push_back(s);
  getline(ss, s, ',');
  int n = stoi(s);
  for (int i = 0; i < n; ++i) dfs(d + 1);
}
int main() {
  cin >> input;
  ss << input;
  while (!ss.eof()) dfs(1);
  int d = 0;
  while (a[d + 1].size()) ++d;
  cout << d << endl;
  for (int i = 1; i <= d; ++i) {
    for (auto s : a[i]) cout << s << " ";
    cout << endl;
  }
}
