#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
long long ipow(long long base, long long exp) {
  if (exp == 0) return 1ll * 1;
  long long result = 1;
  for (;;) {
    if (exp & 1) {
      result *= base;
      result = result % 10000000;
    }
    exp >>= 1;
    if (!exp) break;
    base *= base;
    base = base % 10000000;
  }
  return result % 10000000;
}
int i, level;
vector<string> v;
map<int, vector<string>> mp;
void dfs(int l) {
  level = max(level, l + 1);
  string s = v[i];
  i++;
  string num = v[i];
  i++;
  mp[l].push_back(s);
  int n = 0;
  for (int j = 0; j < num.size(); j++) {
    n = n * 10 + num[j] - '0';
  }
  for (int j = 0; j < n; j++) {
    dfs(l + 1);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  auto start = high_resolution_clock::now();
  string str;
  cin >> str;
  stringstream ss(str);
  while (ss.good()) {
    string substr;
    getline(ss, substr, ',');
    v.push_back(substr);
  }
  for (; i < v.size();) dfs(0);
  cout << mp.size();
  for (auto i : mp) {
    cout << endl;
    for (int j = 0; j < mp[i.first].size(); j++) cout << mp[i.first][j] << " ";
  }
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start);
}
