#include <bits/stdc++.h>
using namespace std;
int main() {
  char ch[101];
  int bcount[101], count = 0;
  for (int i = 1; i < 101; i++) {
    bcount[i] = 0;
  }
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> ch[i];
  }
  int b = 0;
  for (int i = 1; i <= n; i++) {
    if (ch[i] == 'B')
      count++;
    else if (count != 0) {
      bcount[++b] = count;
      count = 0;
    }
    if (i == n)
      if (count != 0) bcount[++b] = count;
  }
  cout << b << endl;
  int c = 1;
  while (bcount[c] != 0) {
    cout << bcount[c] << " ";
    c++;
  }
  return 0;
}
