#include <bits/stdc++.h>
using namespace std;
template <typename T>
T getint() {
  T x = 0, p = 1;
  char ch;
  do {
    ch = getchar();
  } while (ch <= ' ');
  if (ch == '-') p = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * p;
}
template <typename T1, typename T2>
bool umin(T1 &x, const T2 &y) {
  if (x > y) return x = y, true;
  return false;
}
template <typename T1, typename T2>
bool umax(T1 &x, const T2 &y) {
  if (x < y) return x = y, true;
  return false;
}
const int maxn = 1e6 + 10;
const int inf = (int)1e9 + 5;
const int mod = (int)1e9 + 7;
const long long llinf = (long long)1e18 + 5;
const double pi = acos(-1.0);
vector<string> d[maxn];
string next_token(int &i, const string &s) {
  string res = "";
  while (i < s.length() && s[i] != ',') res += s[i++];
  i++;
  return res;
}
int main() {
  string s;
  cin >> s;
  int i = 0;
  vector<int> st;
  st.push_back(inf);
  int mx = 0;
  while (i < s.length()) {
    while (!st.empty() && st.back() == 0) st.pop_back();
    string x = next_token(i, s);
    int c = atoi(next_token(i, s).c_str());
    st.back()--;
    d[st.size()].push_back(x);
    umax(mx, (int)st.size());
    st.push_back(c);
  }
  cout << mx << '\n';
  for (int i = (1); i < (mx + 1); i++) {
    for (auto x : d[i]) cout << x << ' ';
    cout << '\n';
  }
  return 0;
}
