#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, a = 0, b, co = 0, l = 0, i, o = 0, ar[101] = {0};
  cin >> n;
  string s;
  cin >> s;
  b = 0;
  for (i = 0; i < n; ++i) {
    if (s[i] == 'B') {
      if (a == 1)
        l++;
      else
        a = 1, l = 1;
    } else {
      if (a == 1) {
        co++;
        ar[o++] = l;
      }
      a = 0;
      l = 0;
    }
  }
  if (s[i - 1] == 'B') {
    co++;
    ar[o++] = l;
  }
  cout << co << endl;
  for (int i = 0; i < o; ++i) {
    cout << ar[i] << " ";
  }
  return 0;
}
