#include <bits/stdc++.h>
using namespace std;
vector<string> mp[1000050];
string s;
char c[1000050];
int ok = 0, ma;
string get1(int &k) {
  string res;
  if (k == s.size()) {
    ok = 1;
    return res;
  }
  int i;
  for (i = k; i < s.size(); i++) {
    if (s[i] != ',')
      res += s[i];
    else {
      i++;
      break;
    }
  }
  k = i;
  return res;
}
int get2(int &k) {
  if (k == s.size()) {
    ok = 1;
    return 0;
  }
  int res = 0, i;
  for (i = k; i < s.size(); i++) {
    if (s[i] != ',')
      res = res * 10 + (s[i] - '0');
    else {
      i++;
      break;
    }
  }
  k = i;
  return res;
}
void dfs(int n, int &k) {
  if (k == s.size()) {
    ok = 1;
    return;
  }
  string ss = get1(k);
  mp[n].push_back(ss);
  ma = max(ma, n);
  int a = get2(k);
  while (a--) {
    dfs(n + 1, k);
    if (k == s.size()) {
      ok = 1;
      return;
    }
  }
  return;
}
int main() {
  cin >> s;
  int gg = 0;
  while (!ok) dfs(0, gg);
  printf("%d\n", ma + 1);
  for (int i = 0; i <= ma; i++) {
    for (int j = 0; j < mp[i].size(); j++) {
      cout << mp[i][j] << " ";
    }
    puts("");
  }
  return 0;
}
