#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string ans;
  int n;
  cin >> n;
  cin >> ans;
  int values[200], actual = 0;
  int curent = 0, best = 0;
  for (int i = 0; i < n; i++) {
    if (ans[i] == 'B') {
      curent++;
    } else if (curent != 0) {
      actual++;
      values[actual] = curent;
      curent = 0;
    }
    if (i == n - 1 && curent != 0) {
      actual++;
      values[actual] = curent;
      curent = 0;
    }
  }
  cout << actual << "\n";
  for (int i = 1; i <= actual; i++) {
    cout << values[i] << ' ';
  }
  return (0);
}
