#include <bits/stdc++.h>
using namespace std;
long long int powm(long long int a, int b, int n) {
  long long int rm = 1;
  while (b) {
    if (b % 2) {
      rm = (rm * a) % n;
    }
    a = (a * a) % n;
    b /= 2;
  }
  return rm;
}
vector<string> vec;
string s, one;
vector<string> ans[int(1e6 + 1000)];
int mxl = 0;
int geti(string val) {
  int num = 0;
  for (int i = 0; i < val.size(); ++i) num = num * 10 + val[i] - '0';
  return num;
}
bool isDigit(string value) {
  if (value[0] >= '0' && value[0] <= '9')
    return true;
  else
    return false;
}
int print_f(int ind, int L) {
  mxl = max(mxl, L);
  ans[L].push_back(vec[ind]);
  int nc = geti(vec[ind + 1]);
  ind += 2;
  while (nc--) {
    ind = print_f(ind, L + 1);
  }
  return ind;
}
int main() {
  cin >> s;
  one = "";
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == ',') {
      vec.push_back(one);
      one = "";
    } else
      one += s[i];
  }
  vec.push_back(one);
  int ind = 0;
  int n = vec.size() - 1;
  while (ind <= n) {
    ind = print_f(ind, 1);
  }
  cout << mxl << endl;
  for (int i = 1; i <= mxl; ++i) {
    for (int j = 0; j < ans[i].size(); ++j) {
      cout << ans[i][j];
      if (j == ans[i].size() - 1)
        cout << endl;
      else
        cout << " ";
    }
  }
  return 0;
}
