#include <bits/stdc++.h>
using namespace std;
template <class T>
T power(T N, T P) {
  return (P == 0) ? 1 : N * power(N, P - 1);
}
template <class T>
T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T1>
void deb(T1 e1) {
  cout << e1 << 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;
}
int dx[] = {0, 1, 0, -1, -1, 1, 1, -1};
int dy[] = {1, 0, -1, 0, 1, 1, -1, -1};
int xx[] = {-1, 1, 2, 2, 1, -1, -2, -2};
int yy[] = {2, 2, 1, -1, -2, -2, -1, 1};
string st;
vector<string> ans[1000010];
int n;
int rec(int pos, int lev) {
  string tt = "";
  while (pos < n) {
    if (st[pos] == ',') break;
    tt += st[pos++];
  }
  ans[lev].push_back(tt);
  int num = 0;
  pos++;
  while (pos < n) {
    if (st[pos] == ',') break;
    num = (num * 10) + (st[pos++] - '0');
  }
  if (num == 0) return pos;
  while (num--) pos = rec(pos + 1, lev + 1);
  return pos;
}
int main() {
  int pos, i, j, k, cnt;
  cin >> st;
  n = st.size();
  pos = -1;
  while (pos + 1 < n) {
    pos = rec(pos + 1, 0);
  }
  cnt = 0;
  for (i = 0; i < 1000010; i++) {
    if (ans[i].size() == 0) break;
    cnt++;
  }
  printf("%d\n", cnt);
  for (i = 0; i < cnt; i++) {
    for (j = 0; j < ans[i].size(); j++) cout << ans[i][j] << " ";
    printf("\n");
  }
  return 0;
}
