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