#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  string str;
  cin >> str;
  vector<int> ans;
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (str[i] == 'B')
      ++cnt;
    else if (cnt) {
      ans.push_back(cnt);
      cnt = 0;
    }
  }
  if (cnt) {
    ans.push_back(cnt);
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); ++i) {
    cout << ans[i] << " ";
  }
}
int main(void) {
  std::ios_base::sync_with_stdio(false);
  solve();
  return 0;
}
