#include <bits/stdc++.h>
using namespace std;
char str[1000];
int main() {
  int n;
  cin >> n;
  scanf("%s", str);
  vector<int> ans;
  int pre = 0;
  for (int i = 0; str[i]; ++i) {
    if (str[i] == 'W' && pre) {
      ans.push_back(pre);
      pre = 0;
    } else if (str[i] == 'B') {
      pre += 1;
    }
  }
  if (pre) ans.push_back(pre);
  cout << ans.size() << endl;
  if (ans.size()) cout << ans[0];
  for (int i = 1; i < ans.size(); ++i) {
    cout << " " << ans[i];
  }
  if (ans.size()) cout << endl;
  return 0;
}
