#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
string in;
vector<string> pr[N], save;
int ln, dpth, sz, maxd;
bool vis[N];
int Fun(string x) {
  int ret = 0, ln = x.size(), t = 1;
  for (int i = ln - 1; i >= 0; i--) ret += (t * (x[i] - '0')), t *= 10;
  return ret;
}
int Solve(int pos, int dp, int cnt) {
  if (pos >= ln || vis[pos]) return 0;
  vis[pos] = 1, vis[pos + 1] = 1;
  maxd = max(maxd, dp);
  pr[dp].push_back(save[pos]), pos += 2;
  int ret = cnt * 2, en = pos + (2 * cnt);
  for (int i = pos; i < min(ln, en); i += 2) {
    int x = Solve(i, dp + 1, Fun(save[i + 1]));
    en += x, i += x, ret += x;
  }
  return ret;
}
int main() {
  cin >> in;
  ln = in.size();
  for (int i = 0; i < ln; i++) {
    string tmp;
    while (i < ln && in[i] != ',') tmp += in[i], i++;
    save.push_back(tmp);
  }
  sz = save.size();
  for (int i = 0; i < sz; i++)
    if (!vis[i]) Solve(i, 0, Fun(save[i + 1]));
  cout << maxd + 1 << "\n";
  for (int i = 0; i <= maxd; i++) {
    for (int j = 0; j < pr[i].size(); j++) {
      cout << pr[i][j] << " ";
    }
    cout << "\n";
  }
  return 0;
}
