#include <bits/stdc++.h>
using namespace std;
int n, res, am;
int check;
string word;
queue<int> q;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  cin >> word;
  for (int i = 0; i < n; i++) {
    if (word[i] == 'B') {
      check = 1;
      res++;
    }
    if (word[i] == 'W' || (check > 0 && i == (n - 1))) {
      if (check == 1) {
        q.push(res);
        res = 0;
        check = 0;
        am++;
      }
    }
  }
  cout << am << endl;
  if (q.empty() == 1) return 0;
  while (!q.empty()) {
    cout << q.front() << " ";
    q.pop();
  }
}
