#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int n;
  cin >> n >> s;
  vector<int> vec;
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] == 'B') {
      int res = 0;
      while (i < s.length() && s[i] == 'B') {
        ++res;
        ++i;
      }
      vec.push_back(res);
      continue;
    }
  }
  cout << vec.size() << '\n';
  for (int i = 0; i < (int)vec.size(); ++i) {
    cout << vec[i] << ' ';
  }
  cout << '\n';
}
