#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  char arr[n + 1];
  int ans[n / 2 + 1], j = 0, cnt = 0;
  cin >> arr;
  for (int i = 0; i < n;) {
    cnt = 0;
    if (arr[i] == 'B') {
      cnt++;
      i++;
      while (i < n && arr[i] == 'B') {
        i++;
        cnt++;
      }
      ans[j++] = cnt;
    }
    i++;
  }
  cout << j << endl;
  for (int i = 0; i < j; i++) cout << ans[i] << " ";
  return 0;
}
