#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string s;
  cin >> s;
  bool b = 0;
  vector<int> v;
  int cnt = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'B') {
      b = 1;
      cnt++;
    } else if (s[i] == 'W' && b) {
      v.push_back(cnt);
      cnt = 0;
      b = 0;
    }
    if (s[i] == 'B' && i == s.length() - 1) {
      v.push_back(cnt);
    }
  }
  cout << v.size() << "\n";
  for (int i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
  return 0;
}
