#include <bits/stdc++.h>
using namespace std;
int n, x, m = 0, k[103];
string s;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  cin >> s;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'B') {
      x++;
      if (s[i + 1] != 'B') {
        k[m] = x;
        m++;
        x = 0;
      }
    }
  }
  cout << m << endl;
  for (int i = 0; i < m; i++) cout << k[i] << " ";
  return 0;
}
