#include <bits/stdc++.h>
using namespace std;
int n, m;
int main() {
  cin >> n;
  int a[n];
  for (int i = 0; i < n; ++i) {
    char c;
    cin >> c;
    if (c == 'B')
      a[i] = 1;
    else
      a[i] = 0;
  }
  vector<int> ans;
  int cur = 0;
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] == 1)
      cur++;
    else {
      if (cur != 0) {
        ans.push_back(cur);
        cnt++;
      }
      cur = 0;
    }
  }
  if (cur != 0) {
    cnt++;
    ans.push_back(cur);
  }
  cout << cnt << endl;
  for (int i = 0; i < cnt; ++i) cout << ans[i] << " ";
  return 0;
}
