#include <bits/stdc++.h>
using namespace std;
void solution() {
  int length, temp_size = 0, ans_size = 0;
  cin >> length;
  vector<int> blacks;
  char input;
  while (length--) {
    cin >> input;
    if (input == 'B') {
      temp_size++;
    } else {
      if (temp_size != 0) {
        blacks.push_back(temp_size);
        temp_size = 0;
        ans_size++;
      }
    }
  }
  if (temp_size != 0) {
    blacks.push_back(temp_size);
    temp_size = 0;
    ans_size++;
  }
  cout << ans_size << "\n";
  for (auto i : blacks) {
    cout << i << " ";
  }
}
int main() {
  solution();
  return 0;
}
