#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  vector<int> v;
  string s;
  cin >> n >> s;
  s += " ";
  k = 1;
  for (int i = 0; i < s.length() - 1; i++) {
    if (s[i + 1] == s[i]) {
      k++;
    } else {
      if (s[i] == 'B') {
        v.push_back(k);
      }
      k = 1;
    }
  }
  if (v.size()) {
    cout << v.size() << "\n";
    for (int i = 0; i < v.size(); i++) {
      cout << v[i] << " ";
    }
  } else {
    cout << 0 << "\n";
  }
  return 0;
}
