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