#include <bits/stdc++.h>
using namespace std;
int n;
string s;
void load() { cin >> n >> s; }
void solve() {
  vector<int> v;
  int br = 0;
  for (int i = 0; i < n; i++) {
    char c = s[i];
    if (c == 'B') {
      br++;
    } else {
      if (br) v.push_back(br);
      br = 0;
    }
  }
  if (br) v.push_back(br);
  cout << v.size() << endl;
  for (int i = 0; i < (int)v.size(); i++) {
    cout << v[i] << " ";
  }
  cout << endl;
}
int main() {
  load();
  solve();
  return 0;
}
