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