#include <bits/stdc++.h>
using namespace std;
const long long MX = 2e5 + 5;
const long long INF = 1e18;
void print(long long a[], long long n) {
  for (long long i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
  cout << endl;
}
void print(vector<long long> &v) {
  for (long long i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
  cout << endl;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  string s;
  cin >> n >> s;
  long long cnt = 0;
  vector<long long> v;
  for (long long i = 0; i < s.size(); i++) {
    if (s[i] == 'B') {
      cnt++;
    } else {
      if (cnt != 0) {
        v.push_back(cnt);
      }
      cnt = 0;
    }
  }
  if (s[s.size() - 1] == 'B') {
    v.push_back(cnt);
  }
  cout << v.size() << endl;
  print(v);
  return 0;
}
