#include <bits/stdc++.h>
using namespace std;
const int INF = 0x7fffffff;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int MOD = 1000000007;
const int N = 100005;
int now;
int id = 0;
string in;
struct ct {
  int id;
  int layer;
  string s;
  vector<int> next;
  int cnt;
};
vector<ct> vvv;
ct rt;
vector<int> fr;
int dr = 0;
void cons(int layer) {
  string s;
  while (in[now] != ',') s += in[now++];
  now++;
  int tmp = 0;
  while (in[now] != ',') {
    tmp *= 10;
    tmp += in[now++] - '0';
  }
  now++;
  ct c;
  c.layer = layer;
  c.cnt = tmp;
  c.s = s;
  c.id = ++id;
  vvv.push_back(c);
}
void dfs(int rt) {
  dr = max(dr, vvv[rt].layer);
  for (int i = 0; i < vvv[rt].cnt; i++) {
    cons(vvv[rt].layer + 1);
    vvv[rt].next.push_back(id);
    dfs(id);
  }
}
queue<int> fq;
void bfs() {
  int now_layer = 1;
  while (!fq.empty()) {
    int tmp = fq.front();
    fq.pop();
    if (now_layer != vvv[tmp].layer) {
      now_layer = vvv[tmp].layer;
      cout << endl;
    }
    cout << vvv[tmp].s << ' ';
    for (int i = 0; i < vvv[tmp].next.size(); i++) {
      fq.push(vvv[tmp].next[i]);
    }
  }
}
int main() {
  cin >> in;
  in += ',';
  string s;
  ct ttt;
  vvv.push_back(ttt);
  while (now < in.length()) {
    cons(1);
    fq.push(id);
    dfs(id);
  }
  printf("%d\n", dr);
  bfs();
}
