#include <bits/stdc++.h>
using namespace std;
const long long linf = 1e18 + 5;
const int mod = (int)1e9 + 7;
const int inf = 1e9;
long long read() {
  bool minus = false;
  long long result = 0;
  char ch;
  ch = getchar();
  while (true) {
    if (ch == '-') break;
    if (ch >= '0' && ch <= '9') break;
    ch = getchar();
  }
  if (ch == '-')
    minus = true;
  else
    result = ch - '0';
  while (true) {
    ch = getchar();
    if (ch < '0' || ch > '9') break;
    result = result * 10 + (ch - '0');
  }
  if (minus) {
    return -result;
  } else {
    return result;
  }
}
long long fpow(long long base, long long power) {
  long long result = 1;
  while (power > 0) {
    if (power % 2 == 1) result = (result * base);
    base = (base * base);
    power /= 2;
  }
  return result;
}
int glo = 0, md = 0;
vector<pair<string, int> > v;
map<int, vector<string> > ans;
void dfs(int d) {
  if (glo >= v.size()) {
    return;
  }
  md = max(d, md);
  ans[d].push_back(v[glo].first);
  int y = v[glo].second;
  glo++;
  while (y--) {
    dfs(d + 1);
  }
  if (d == 1) {
    if (glo < v.size()) dfs(d);
  }
}
string str;
void parse() {
  for (int i = 0; i < str.size(); i++) {
    if (str[i] == ',') str[i] = ' ';
  }
  stringstream ss(str);
  string x;
  int xy;
  while (ss >> x >> xy) {
    v.push_back(make_pair(x, xy));
  }
  dfs(1);
}
int main() {
  cin >> str;
  parse();
  printf("%d\n", md);
  for (int i = 1; i <= md; ++i) {
    for (int j = 0; j < ans[i].size(); ++j) {
      if (j > 0) printf(" ");
      printf("%s", ans[i][j].c_str());
    }
    if (i != md) printf("\n");
  }
  return 0;
}
