#include <bits/stdc++.h>
using namespace std;
const long long max_n = 1e5 + 20;
int32_t main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long n, m, ans = 0, cnt = 0;
  vector<long long> r;
  string s;
  cin >> n >> s;
  for (long long i = 0; i < n; i++) {
    if (s[i] == 'W' && cnt)
      r.push_back(cnt), cnt = 0, ans++;
    else if (s[i] == 'B')
      cnt++;
  }
  if (cnt) r.push_back(cnt), ans++;
  cout << ans << endl;
  for (long long i = 0; i < ans; i++) cout << r[i] << " ";
  return 0;
}
