#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int k;
  cin >> k;
  string s;
  cin >> s;
  vector<int> res;
  int cntSoFar = 0;
  for (int i = 0; i < k; ++i) {
    if (s[i] == 'B')
      cntSoFar++;
    else if (cntSoFar) {
      res.push_back(cntSoFar);
      cntSoFar = 0;
    } else
      cntSoFar = 0;
  }
  if (cntSoFar) res.push_back(cntSoFar);
  cout << res.size() << "\n";
  for (int i = 0; i < (int)res.size(); ++i)
    if (i == 0)
      cout << res[i];
    else
      cout << " " << res[i];
  cout << "\n";
  return 0;
}
