#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  char s[n + 1];
  cin >> s;
  int c[n];
  int i, j, k;
  for (i = 0, j = 0, k = 0; i < n; i++) {
    if (s[i] == 'B')
      j++;
    else {
      if (j > 0) c[k++] = j;
      j = 0;
    }
  }
  if (j > 0) c[k++] = j;
  cout << k << '\n';
  for (i = 0; i < k; i++) cout << c[i] << ' ';
  return 0;
}
