#include <bits/stdc++.h>
using namespace std;
long long t, a[1009], res, r = 1, n, i, rr;
int main() {
  string s;
  cin >> n;
  cin >> s;
  for (i = 0; i < s.size(); i++) {
    if (s[i] == 'B') {
      a[r]++;
    } else {
      r++;
      res = 0;
    }
  }
  for (i = 1; i <= r; i++) {
    if (a[i] == 0) {
      rr++;
    }
  }
  cout << r - rr << endl;
  for (i = 1; i <= r; i++) {
    if (a[i] > 0) {
      cout << a[i] << " ";
    }
  }
}
