#include <bits/stdc++.h>
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
string S[1000000];
int num[1000000];
string s;
void parse(int f, int l, int r) {
  while (s[l] != ',') {
    S[f] += s[l];
    l++;
  }
  l++;
  while (s[l] != ',') {
    num[f] = num[f] * 10 + (s[l] - '0');
    l++;
  }
  return;
}
bool vis[1000000];
int id;
vector<int> ret[1000000];
int mx = 0;
void dfs(int lev) {
  mx = max(mx, lev);
  ret[lev].push_back(id);
  vis[id] = 1;
  int k = num[id];
  for (int j = 0; j < k; j++) {
    id++;
    dfs(lev + 1);
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t = 1;
  while (t--) {
    cin >> s;
    int z = 0;
    int l = 0;
    s += ",";
    int n = 0;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == ',') z++;
      if (z % 2 == 0 && z > 0 && s[i] == ',') parse(n, l, i), n++, l = i + 1;
    }
    for (int i = 0; i < n; i++)
      if (!vis[i]) id = i, dfs(0);
    cout << mx + 1 << endl;
    for (int i = 0; i <= mx; i++) {
      for (int j = 0; j < ret[i].size(); j++) cout << S[ret[i][j]] << ' ';
      cout << endl;
    }
  }
  return 0;
}
