#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, n, b = 1, k = 0, a[51], g = 0;
  cin >> n;
  char s[n + 2];
  cin >> s;
  s[n] = 'W';
  s[n + 1] = 'W';
  for (i = 0; i < n + 1; i++) {
    if (s[i] == 'B') {
      for (j = i; j < n + 1; j++) {
        if (s[j] == 'B' && s[j + 1] == 'B') {
          b++;
        }
        if (s[j] == 'W') {
          a[k] = b;
          k++;
          b = 1;
          i = j;
          break;
        }
      }
    }
  }
  cout << k << "\n";
  for (i = 0; i < k; i++) {
    cout << a[i] << " ";
  }
  return 0;
}
