#include <bits/stdc++.h>
using namespace std;
int a[100001];
int main() {
  int n;
  cin >> n;
  string s;
  for (int i = 0; i < n; i++) cin >> s;
  int group = 0;
  bool flag = false;
  for (int i = 0; i < n; i++) {
    if ((s[i] == 'B') && (!flag)) {
      flag = true;
    }
    if (s[i] == 'B') a[group]++;
    if ((s[i] == 'W') && (flag)) {
      flag = false;
      group++;
    }
  }
  if (s[s.length() - 1] == 'B') group++;
  cout << group << endl;
  for (int i = 0; i < group; i++) cout << a[i] << ' ';
}
