#include <bits/stdc++.h>
using namespace std;
int len, cc;
char buf[233];
vector<int> ans;
int main() {
  scanf("%d", &len);
  scanf("%s", buf);
  for (int i = 0; i < len; ++i) {
    if (buf[i] == 'B')
      ++cc;
    else {
      if (cc) ans.push_back(cc);
      cc = 0;
    }
  }
  if (cc) ans.push_back(cc);
  printf("%d\n", ans.size());
  for (auto&& x : ans) printf("%d ", x);
}
