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