#include <bits/stdc++.h>
using namespace std;
inline bool isEq(double a, double b) { return (abs(a - b) < 1e-9); }
inline int negModHandler(int a, int d) {
  return ((a % d) < 0) ? d + (a % d) : (a % d);
}
int main() {
  int n;
  string str;
  cin >> n;
  cin >> str;
  int nn = 0, ara[105];
  for (int i = 0; i < str.length(); i++) {
    int s = 0;
    while (i < str.length() && str[i] == 'B') {
      i++;
      s++;
    }
    if (s) {
      ara[nn++] = s;
    }
  }
  cout << nn << '\n';
  for (int i = 0; i < nn; i++) cout << ara[i] << " ";
  return 0;
}
