#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  char arr[100005];
  cin >> arr;
  vector<int> brr;
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] != 'B') {
      if (count != 0) brr.push_back(count);
      count = 0;
    } else
      count++;
  }
  if (count != 0) brr.push_back(count);
  cout << brr.size() << endl;
  for (int i = 0; i < brr.size(); i++) cout << brr[i] << " ";
}
