#include <bits/stdc++.h>
using namespace std;
template <typename T>
string to_string(T str) {
  stringstream stream;
  stream << str;
  return stream.str();
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  vector<int> v;
  int n;
  cin >> n;
  string s;
  cin >> s;
  s += 'W';
  int count = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'B') {
      count++;
    } else {
      if (count != 0) {
        v.push_back(count);
      }
      count = 0;
    }
  }
  cout << v.size() << endl;
  if (v.size() != 0) {
    for (int i = 0; i < v.size(); i++) {
      cout << v[i] << " ";
    }
    cout << endl;
    ;
  }
  return 0;
}
