#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x7fffffff;
const long long mod = 1e9 + 7;
const double eps = 1e-8;
const long long linf = 1e18;
const long long MAXN = 5e5 + 10;
const long long MAXM = 1e6 + 10;
const double E = 2.718281828;
const double pi = acos(-1.0);
vector<string> g[MAXN];
string second;
char s[MAXN << 1];
int i;
int len;
int maxn = 1;
string getss() {
  string t = "";
  for (; i < len; ++i) {
    if (s[i] == ',') {
      ++i;
      return t;
    }
    t += s[i];
  }
}
int getnum() {
  int ans = 0;
  while (i < len && s[i] != ',') {
    ans = ans * 10 + s[i] - '0';
    ++i;
  }
  ++i;
  return ans;
}
void dfs(int deep) {
  maxn = max(maxn, deep);
  second = getss();
  int num = getnum();
  g[deep].push_back(second);
  for (int i = 0; i < num; ++i) dfs(deep + 1);
}
int main() {
  scanf("%s", s);
  len = strlen(s);
  while (i < len) {
    second = getss();
    int num = getnum();
    g[1].push_back(second);
    for (int i = 0; i < num; ++i) dfs(2);
  }
  printf("%d\n", maxn);
  for (int i = 1; i <= maxn; ++i) {
    for (int j = 0; j < g[i].size(); ++j) {
      cout << g[i][j];
      if (j != g[i].size() - 1)
        cout << " ";
      else
        cout << endl;
    }
  }
  return 0;
}
