#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 1e6 + 10;
int vis[N];
string s;
int len, mx;
int last;
vector<string> ans[N];
void dfs(int indx, int lev = 0) {
  if (vis[indx]) return;
  if (indx >= len) return;
  mx = max(mx, lev);
  int l = indx;
  string temp;
  while (l < len && isalpha(s[l])) {
    vis[l] = 1;
    last = max(l, last);
    temp += s[l++];
  }
  if ((int)(temp.size()) > 0) ans[lev].push_back(temp);
  vis[l] = 1;
  last = max(l, last);
  l++;
  string num;
  while (l < len && isdigit(s[l])) {
    vis[l] = 1;
    last = max(l, last);
    num += s[l++];
  }
  vis[l] = 1;
  last = max(l, last);
  l++;
  int nnum = stoi(num);
  while (nnum--) {
    dfs(l, lev + 1);
    int cnt = 0;
    l = last + 1;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> s;
  len = s.size();
  for (int i = 0; i < len; i++)
    if (!vis[i]) dfs(i);
  cout << mx + 1 << "\n";
  for (int i = 0; i <= mx; i++) {
    for (auto it : ans[i]) cout << it << " ";
    cout << "\n";
  }
  return 0;
}
