#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
inline void checkmin(T& x, U y) {
  x = min(x, (T)y);
};
template <class T, class U>
inline void checkmax(T& x, U y) {
  x = max(x, (T)y);
};
int Cnt[5050], tCnt;
void process(string& doc) {
  int n = ((int)(doc.size()));
  tCnt = 0;
  memset(Cnt, 0, sizeof Cnt);
  vector<int> res;
  for (int i = 0; i < n;) {
    if (i + 7 <= n and doc.substr(i, 7) == "<table>") {
      Cnt[tCnt++] = 0;
      i += 7;
    } else if (i + 8 <= n and doc.substr(i, 8) == "</table>") {
      res.push_back(Cnt[--tCnt]);
      i += 8;
    } else if (i + 4 <= n and doc.substr(i, 4) == "<td>") {
      for (int j = (tCnt - 1); j < (tCnt); ++j) Cnt[j]++;
      i += 4;
    } else if (i + 5 <= n and doc.substr(i, 5) == "</td>") {
      i += 5;
    } else
      i++;
  }
  sort((res).begin(), (res).end());
  for (int i = (0); i < (((int)(res.size()))); ++i) cout << res[i] << endl;
  return;
}
int main() {
  string doc = "";
  for (string line; cin >> line; doc += line)
    ;
  process(doc);
  return 0;
}
