#include <bits/stdc++.h>
using namespace std;
const long long inf = (1ll << 62) - 1;
const long long MOD = 1e9 + 7;
const int MAX = 1e9;
const int N = 2e5 + 10;
using namespace std;
int bPow(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1ll) {
      res = 1ll * res * a % MOD;
    }
    b >>= 1;
    a = 1ll * a * a % MOD;
  }
  return res;
}
int gcd(int a, int b) {
  if (a < b) {
    swap(a, b);
  }
  if (b == 0) return a;
  return gcd(b, a % b);
}
vector<int> mpf(N, 0);
void sieve() {
  for (int i = 2; i < N; ++i) {
    if (!mpf[i])
      for (int j = 2 * i; j < N; j += i) {
        mpf[j] = i;
      }
  }
}
int maxLevel = 0;
map<int, vector<string>> hashMap;
void dfs(stringstream& ss, string cur, int level) {
  maxLevel = max(maxLevel, level);
  hashMap[level].push_back(cur);
  string n;
  getline(ss, n, ',');
  int num = stoi(n);
  for (int i = 1; i <= num; ++i) {
    string next;
    getline(ss, next, ',');
    dfs(ss, next, level + 1);
  }
}
void solve() {
  string s, cur;
  cin >> s;
  stringstream ss(s);
  while (getline(ss, cur, ',')) dfs(ss, cur, 1);
  cout << maxLevel << endl;
  for (auto& hm : hashMap) {
    for (auto& i : hm.second) {
      cout << i << " ";
    }
    cout << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  solve();
  return 0;
}
