#include <bits/stdc++.h>
using namespace std;
const int MX = 2e6 + 10;
const int mod = 1e9 + 7;
const long long int inf = 1LL << 62;
int dx4[] = {0, 0, -1, 1};
int dy4[] = {1, -1, 0, 0};
int dx[] = {1, 1, 1, 0, 0, -1, -1, -1};
int dy[] = {1, 0, -1, 1, -1, 1, 0, -1};
long long int ar[MX], br[MX];
set<long long int> st;
string str;
struct Node {
  string str;
  long long int edg;
};
Node vec[MX];
vector<long long int> ans[MX];
long long int cnt = 1;
long long int mx = 0;
void dfs(long long int lvl, long long int cur) {
  mx = max(mx, lvl);
  ans[lvl].push_back(cnt);
  cnt++;
  for (int i = 1; i <= cur; i++) {
    dfs(lvl + 1, vec[cnt].edg);
  }
}
int main() {
  long long int n, m, k, q, t, idx = 1, sum = 0, mn = inf;
  cin >> str;
  n = str.size();
  for (int i = 0; i < n; i++) {
    string x;
    if (isalpha(str[i]))
      x += str[i];
    else
      continue;
    while (isalpha(str[i + 1]) && i + 1 < n) {
      i++;
      x += str[i];
    }
    vec[idx].str = x;
    idx++;
  }
  idx = 1;
  for (int i = 0; i < n; i++) {
    long long int x = 0;
    if (str[i] >= '0' && str[i] <= '9')
      x = str[i] - '0';
    else
      continue;
    while (str[i + 1] >= '0' && str[i + 1] <= '9' && i + 1 < n) {
      i++;
      x = x * 10 + str[i] - '0';
    }
    vec[idx].edg = x;
    idx++;
  }
  while (cnt <= idx) {
    dfs(1, vec[cnt].edg);
  }
  cout << (mx) << endl;
  for (int i = 1; i <= mx; i++) {
    for (auto x : ans[i]) cout << (vec[x].str) << " ";
    cout << endl;
  }
  return 0;
}
