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