#include <bits/stdc++.h>
using namespace std;
bool flag = true;
inline int read() {
  int X = 0, w = 0;
  char ch = 0;
  while (!isdigit(ch)) {
    w |= ch == '-';
    ch = getchar();
  }
  while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
  if (ch != ',') flag = false;
  return w ? -X : X;
}
inline string reads() {
  string s = "";
  char ch;
  while ((ch = getchar()) != ',') s += ch;
  return s;
}
vector<string> ve[(500000 + 10)];
int MAX = -1;
void work(int x) {
  MAX = max(MAX, x);
  string s = reads();
  int t = read();
  ve[x].push_back(s);
  for (int i = 1; i <= t; i++) work(x + 1);
}
int main() {
  ios::sync_with_stdio(false);
  while (flag) work(0);
  cout << MAX + 1 << endl;
  for (int i = 0; i <= MAX; i++) {
    int n = ve[i].size();
    cout << ve[i][0];
    for (int j = 1; j < n; j++) cout << ' ' << ve[i][j];
    cout << endl;
  }
  return 0;
}
