#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int x = 0, y = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'B') {
      y = y + 1;
    } else {
      if (y > 0) {
        x = x + 1;
        y = 0;
      }
    }
  }
  if (y > 0) {
    x = x + 1;
  }
  int z[x], h = 0, j = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'B') {
      h = h + 1;
    } else {
      if (h > 0) {
        z[j] = h;
        h = 0;
        j++;
      }
    }
  }
  if (s[n - 1] == 'B') {
    z[x - 1] = h;
  }
  cout << x << endl;
  for (int i = 0; i < x; i++) {
    cout << z[i] << " ";
  }
  return 0;
}
