#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 0x3c3c3c3c;
const long long INFL = 0x3c3c3c3c3c3c3c3c;
const int MAX_N = 102;
string S;
stack<int> s;
vector<string> ans[1000000];
int main() {
  cin >> S;
  s.push(INF);
  int prev = 0;
  int cnt = 0;
  string str;
  string pushStr;
  int num;
  int depth = 0;
  for (int i = 0; i < S.size(); ++i) {
    if (S[i] != ',') continue;
    cnt++;
    str = S.substr(prev, i - prev);
    prev = i + 1;
    if (cnt % 2 == 0) {
      num = stoi(str);
      while (s.top() == 0) {
        s.pop();
        depth--;
      }
      int t = s.top();
      s.pop();
      s.push(t - 1);
      ans[depth].push_back(pushStr);
      if (num == 0) continue;
      s.push(num);
      depth++;
    } else
      pushStr = str;
  }
  str = S.substr(prev, S.size());
  num = stoi(str);
  while (s.top() == 0) {
    s.pop();
    depth--;
  }
  int t = s.top();
  s.pop();
  s.push(t - 1);
  ans[depth].push_back(pushStr);
  if (num != 0) {
    s.push(num);
    depth++;
  }
  int ansCnt = 0;
  for (int i = 0; i < 1000000; ++i) {
    if (ans[i].size() == 0) break;
    ansCnt++;
  }
  printf("%d\n", ansCnt);
  for (int i = 0; i < 1000000; ++i) {
    if (ans[i].size() == 0) break;
    for (int j = 0; j < ans[i].size(); ++j) {
      cout << ans[i][j] << " ";
    }
    cout << "\n";
  }
  return 0;
}
