#include <bits/stdc++.h>
void solve() {
  int n;
  std::cin >> n;
  std::string s;
  std::cin >> s;
  std::vector<int> a;
  for (size_t pos = 0; pos < s.size(); ++pos) {
    if (s[pos] == 'B') {
      int c = 0;
      while (pos < s.size() && s[pos] == 'B') {
        ++c;
        ++pos;
      }
      a.push_back(c);
    }
  }
  std::cout << a.size() << "\n";
  for (int x : a) {
    std::cout << x << " ";
  }
}
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  solve();
  return 0;
}
