#include <bits/stdc++.h>
using namespace std;
int cntLet[150];
int main() {
  long long n, k = 0, cnt = 0;
  vector<int> ans;
  cin >> n;
  string s;
  cin >> s;
  bool f = 0;
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] == 'B') {
      ++k;
    } else {
      if (k) ans.push_back(k);
      k = 0;
    }
  }
  if (s[s.length() - 1] == 'B') ans.push_back(k);
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); ++i) cout << ans[i] << ' ';
  cin >> n;
  return 0;
}
