#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[101] = {0}, gr = 0, cnt = 0, k, l, i, j;
  string s;
  cin >> n;
  cin >> s;
  i = 0;
  k = 0;
  while (i < n) {
    if (s[i] == 'B') {
      for (j = i; j < n; j++) {
        if (s[j] != 'B')
          break;
        else
          cnt++;
      }
      a[k] = cnt;
      i = j - 1;
      cnt = 0;
      k++;
      gr++;
    }
    i++;
  }
  cout << gr << "\n";
  for (i = 0; i < gr; i++) cout << a[i] << " ";
  return 0;
}
