#include <bits/stdc++.h>
using namespace std;
long long ar[100009] = {0};
int main() {
  long long a = 0, b, n = 0, m, x, y, z, i, j, k, t, sum = 0;
  char c, cc;
  string s, ss, sss;
  cin >> n;
  cin >> s;
  for (i = 0; i < n; i++) {
    if (s[i] == 'B') {
      for (j = i; j < n; j++) {
        if (s[j] == 'B')
          ar[a]++;
        else {
          break;
        }
      }
      i = j;
      a++;
    }
  }
  cout << a << endl;
  for (i = 0; i < a; i++) {
    cout << ar[i] << " ";
  }
  return 0;
}
