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