#include <bits/stdc++.h>
using namespace std;
int i, j, n, l, a[110], ct, tem;
string s;
int main() {
  cin >> n >> s;
  for (i = 0; i < n; i++) {
    if (s[i] == 'B')
      ct++;
    else {
      if (ct > 0) {
        a[j++] = ct;
        ct = 0;
      }
    }
  }
  if (s[n - 1] == 'B') a[j++] = ct;
  cout << j << endl;
  for (i = 0; i < j; i++) cout << a[i] << " ";
}
