#include <bits/stdc++.h>
using namespace std;
vector<long long> v1;
vector<long long> v2;
vector<pair<long long, long long> > vp;
int main() {
  ios_base::sync_with_stdio(0);
  long long n, i, j, ctr = 0;
  string s;
  cin >> n >> s;
  int k = 0;
  v1.push_back(0);
  for (i = 0; i < n; i++) {
    if (s[i] == 'B')
      v1[k]++;
    else if (s[i] == 'W') {
      v1.push_back(0);
      k++;
    }
  }
  for (i = 0; i < v1.size(); i++) {
    if (v1[i] != 0) ctr++;
  }
  cout << ctr << "\n";
  for (i = 0; i < v1.size(); i++) {
    if (v1[i] != 0) cout << v1[i] << " ";
  }
  return 0;
}
