#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> v;
  int i, j = 0, k = 0;
  for (i = 0; i < s.size(); i++) {
    while (s[i] == 'B') {
      k++;
      i++;
    }
    if (k > 0) {
      v.push_back(k);
      k = 0;
    }
  }
  cout << v.size() << endl;
  for (int i = 0; i < v.size(); i++) cout << v[i] << " ";
  return 0;
}
