#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, curr = 0;
  cin >> n;
  string s;
  cin >> s;
  vector<int> barr;
  for (int i = 0; i < n; i++) {
    if (s.at(i) == 'B')
      curr++;
    else {
      if (curr != 0) barr.push_back(curr);
      curr = 0;
    }
  }
  if (s.at(n - 1) == 'B') barr.push_back(curr);
  cout << barr.size() << endl;
  for (int i = 0; i < barr.size(); i++) cout << barr.at(i) << ' ';
  return 0;
}
