#include <bits/stdc++.h>
using namespace std;
const double PI = 2.0 * acos(0.0);
const double E = exp(1);
template <class T1>
void deb(T1 e) {
  cout << "-->" << e << endl;
}
template <class T1, class T2>
void deb(T1 e1, T2 e2) {
  cout << "-->" << e1 << " " << e2 << endl;
}
template <class T1, class T2, class T3>
void deb(T1 e1, T2 e2, T3 e3) {
  cout << "-->" << e1 << " " << e2 << " " << e3 << endl;
}
template <class T1, class T2, class T3, class T4>
void deb(T1 e1, T2 e2, T3 e3, T4 e4) {
  cout << "-->" << e1 << " " << e2 << " " << e3 << " " << e4 << endl;
}
template <class T1, class T2, class T3, class T4, class T5>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << endl;
}
template <class T1, class T2, class T3, class T4, class T5, class T6>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5, T6 e6) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << " " << e6
       << endl;
}
template <typename T>
inline T sqr(T n) {
  return n * n;
}
inline double hypot(double x, double y) { return sqrt(sqr(x) + sqr(y)); }
template <typename T>
inline T pmod(T n, T m) {
  return ((n % m) + m) % m;
}
template <typename T>
T power(T n, int p) {
  return (p == 0) ? (T)(1) : (sqr(power(n, p >> 1)) * ((p & 1) * (n - 1) + 1));
}
template <typename T>
T bigmod(T n, int p, T m) {
  return (p == 0)
             ? (T)(1)
             : ((sqr(bigmod(n, p >> 1, m)) % m) * ((p & 1) * (n - 1) % m + 1)) %
                   m;
}
int pos, mx, len;
char line[1000100];
vector<string> ans[1000100];
void rec(int depth) {
  mx = max(mx, depth);
  string str = "";
  while (line[pos] != ',') {
    str += line[pos];
    pos++;
  }
  ans[depth].push_back(str);
  pos++;
  str = "";
  while (line[pos] != ',') {
    str += line[pos];
    pos++;
  }
  istringstream iss(str);
  int x;
  iss >> x;
  for (int i = 0; i < x; i++) {
    pos++;
    rec(depth + 1);
  }
}
int main() {
  scanf("%s", line);
  len = strlen(line);
  while (pos < len) {
    rec(0);
    pos++;
  }
  printf("%d\n", mx + 1);
  for (int i = 0; i <= mx; i++) {
    for (int j = 0; j < (int)ans[i].size() - 1; j++) {
      printf("%s ", ans[i][j].c_str());
    }
    printf("%s\n", ans[i][(int)ans[i].size() - 1].c_str());
  }
  return 0;
}
