#include <bits/stdc++.h>
int main() {
  std::vector<int> values;
  bool start = false;
  char ch;
  int length, ans = 0;
  std::cin >> length;
  for (int i = 0; i < length; i++) {
    std::cin >> ch;
    if (ch == 'B') {
      start = true;
      ans++;
    }
    if (ch == 'W' && start && ans) {
      values.push_back(ans);
      ans = 0;
    }
  }
  if (ans) values.push_back(ans);
  std::cout << values.size() << std::endl;
  for (int i = 0; i < values.size(); i++) std::cout << values.at(i) << " ";
}
