#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string s;
  cin >> n >> s;
  int arr[101], size = 0, cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'B')
      ++cnt;
    else if (cnt != 0) {
      arr[size++] = cnt;
      cnt = 0;
    }
  }
  if (cnt) {
    arr[size++] = cnt;
    cnt = 0;
  }
  cout << size << endl;
  for (int i = 0; i < size; ++i) {
    cout << arr[i] << " ";
  }
  return 0;
}
