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