#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string s;
  vector<int> ans;
  cin >> n >> s;
  s += 'W';
  int cnt = 0;
  for (int i = 0; i <= n; i++)
    if (s[i] == 'B')
      cnt++;
    else {
      if (cnt != 0) ans.push_back(cnt);
      cnt = 0;
    }
  cout << ans.size() << '\n';
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
}
