#include <bits/stdc++.h>
using namespace std;
inline bool endsWith(std::string const& value, std::string const& ending) {
  if (ending.size() > value.size()) return false;
  return std::equal(ending.rbegin(), ending.rend(), value.rbegin());
}
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  string line;
  cin >> line;
  int pos = 0;
  vector<int> res;
  while (pos < line.length()) {
    while (pos < line.length() && line[pos] == 'W') pos++;
    if (pos < line.length()) {
      int j = pos + 1;
      while (j < line.length() && line[j] == 'B') j++;
      res.push_back(j - pos);
      pos = j;
    }
  }
  cout << res.size() << '\n';
  for (int i = 0; i < (res.size()); ++i) cout << res[i] << ' ';
  cout << '\n';
  return 0;
}
