#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[150];
  int n, d, count, i, b[105], count1, j;
  while (cin >> n) {
    cin >> a;
    d = strlen(a);
    count1 = count = 0;
    for (i = 0; i < d; i++) {
      if (a[i] == 'B')
        count++;
      else if (count != 0) {
        b[count1] = count;
        count1++;
        count = 0;
      }
      if (i == d - 1 && a[d - 1] == 'B') {
        b[count1] = count;
        count1++;
      }
    }
    cout << count1 << endl;
    for (j = 0; j < count1; j++) cout << b[j] << " ";
    cout << endl;
  }
  return 0;
}
