#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, i, j, ans = 0, c = 0;
  vector<long long int> v;
  cin >> n;
  string s;
  cin >> s;
  for (i = 0; i < n; i++) {
    if (s[i] == 'B')
      c++;
    else if (c != 0 && s[i] == 'W') {
      v.push_back(c);
      c = 0;
      ans++;
    }
  }
  if (c != 0) {
    v.push_back(c);
    ans++;
  }
  cout << ans << endl;
  for (i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
  if (ans > 0) cout << endl;
  return 0;
}
