#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000005;
vector<string> a;
vector<string> adj[MAXN];
long long int flag = false, var;
long long int rec(long long int node, long long int level) {
  if (node >= (long long int)(a).size()) {
    flag = true;
    return -1;
  }
  adj[level].push_back(a[node]);
  string s1 = a[node + 1];
  reverse(s1.begin(), s1.end());
  long long int no = 0, temp = 1;
  for (int i = 0; i < s1.length(); i++) {
    no += temp * (s1[i] - '0');
    temp *= 10;
  }
  long long int curr = node + 2;
  for (int i = 0; i < no; i++) {
    long long int pos = rec(curr, level + 1);
    if (pos == -1) return -1;
    curr = pos;
  }
  return curr;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string b, str = "";
  cin >> b;
  for (int i = 0; i < b.length(); i++) {
    if (b[i] == ',')
      a.push_back(str), str = "";
    else
      str += b[i];
  }
  a.push_back(str);
  while (!flag) {
    var = rec(var, 0);
  }
  long long int res = 0;
  for (int i = 0; i < MAXN; i++) {
    if ((long long int)(adj[i]).size() == 0) {
      res = i;
      break;
    }
  }
  cout << res << "\n";
  for (int i = 0; i < res; i++) {
    for (int j = 0; j < (long long int)(adj[i]).size(); j++)
      cout << adj[i][j] << " ";
    cout << "\n";
  }
  return 0;
}
