#include <bits/stdc++.h>
using namespace std;
const int block_size = 320;
const long long mod = 1e9 + 7;
const long double eps = 1e-9;
const int inf = mod;
const double PI = atan(1) * 4;
template <typename T>
inline int sign(const T &a) {
  if (a < 0) return -1;
  if (a > 0) return 1;
  return 0;
}
template <typename T>
inline void in(T &x) {
  x = 0;
  T f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
}
string line;
stringstream ss;
map<int, vector<string>> ans;
void output() {
  cout << ((int)ans.size()) << endl;
  for (const auto &v : ans) {
    auto &li = v.second;
    for (const auto &s : li) {
      cout << s << ' ';
    }
    cout << endl;
  }
}
void solve(int cnt = 1000000, int level = 0) {
  string word = "";
  for (long long i = 0; i < cnt; i++)
    if (!(ss >> word)) {
      output();
      exit(0);
      ;
    } else {
      int son = 0;
      ss >> son;
      ans[level].push_back(word);
      if (son) solve(son, level + 1);
    }
}
int main() {
  cin >> line;
  for (auto &i : line) {
    if (i == ',') {
      i = ' ';
    }
  }
  ss << line;
  solve();
  return 0;
}
