#include <bits/stdc++.h>
using namespace std;
const long long INF = 2000000000000000001;
map<string, int> M;
void solve() {
  char c;
  cin >> c;
  string s;
  cin >> s;
  for (int i = 0; i < s.length(); i++)
    if (s[i] % 2)
      s[i] = '1';
    else
      s[i] = '0';
  while (s.length() < 18) s = '0' + s;
  if (c == '+') {
    M[s]++;
  } else if (c == '-') {
    M[s]--;
  } else {
    cout << M[s] << "\n";
  }
}
int main() {
  int a;
  cin >> a;
  string s;
  cin >> s;
  vector<int> ans;
  if (s[0] == 'B') ans.push_back(1);
  for (int i = 1; i < s.length(); i++)
    if (s[i] == 'B' && s[i - 1] == 'B')
      ans[ans.size() - 1]++;
    else if (s[i] == 'B')
      ans.push_back(1);
  cout << ans.size() << "\n";
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  return 0;
}
