#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e6;
string s[MAX];
int num[MAX], cnt, ct, ans, j;
vector<string> de[MAX];
void change(string a) {
  int l = a.length();
  int sum = 0;
  for (int i = 0; i < l; ++i) {
    sum = sum * 10 + a[i] - '0';
  }
  num[ct++] = sum;
}
void dfs(int x, int d) {
  if (x == cnt) return;
  int l = num[x];
  while (num[x] && j < cnt) {
    num[x]--;
    dfs(++j, d + 1);
  }
  if (num[x] == 0) {
    ans = max(ans, d);
    de[d].push_back(s[x]);
    j = max(j, x);
    return;
  }
}
int main() {
  string c, cc;
  cin >> c;
  cnt = ct = 0;
  for (int i = 0; i < c.length(); ++i) {
    if (c[i] != ',')
      cc += c[i];
    else {
      if (cc[0] >= '0' && cc[0] <= '9')
        change(cc);
      else
        s[cnt++] = cc;
      cc = "";
    }
  }
  if (cc[0] >= '0' && cc[0] <= '9')
    change(cc);
  else
    s[cnt++] = cc;
  j = 0;
  while (j < cnt) {
    dfs(j, 1);
    j++;
  }
  printf("%d\n", ans);
  for (int i = 1; i <= ans; ++i) {
    for (int j = 0; j < de[i].size(); ++j) {
      cout << de[i][j] << " ";
    }
    cout << endl;
  }
}
