#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string cad;
  cin >> cad;
  cad = 'W' + cad + 'W';
  std::vector<int> v;
  int cd = 0;
  bool rd = true;
  for (int i = 0; i < n + 2; ++i) {
    if (cad[i] == 'B') {
      cd++;
      rd = true;
    } else {
      if (rd && cd > 0) {
        v.push_back(cd);
        cd = 0;
        rd = false;
      }
    }
  }
  cout << v.size() << endl;
  for (int i = 0; i < v.size(); ++i) {
    cout << v[i] << " ";
  }
  return 0;
}
