#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, grp = 0, k;
  cin >> n;
  string s;
  cin >> s;
  k = -1;
  vector<int> ar;
  if (n > 1) {
    if (s[0] == 'B' && (s[1] == 'W' || s[1] == 'B')) {
      grp++;
      k++;
      ar.push_back(1);
    }
    for (int i = 1; i < n; i++) {
      if (s[i - 1] == 'W' && s[i] == 'B') {
        grp++;
        k++;
        ar.push_back(1);
      } else if (s[i - 1] == 'B' && s[i] == 'B') {
        ar[k]++;
      }
    }
  } else if (s[0] == 'B') {
    grp++;
    ar.push_back(1);
    k++;
  }
  cout << grp << endl;
  for (int i = 0; i <= k; i++) cout << ar[i] << ' ';
}
