#include <bits/stdc++.h>
using namespace std;
int arr[110];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string str;
  cin >> str;
  int t = 0;
  if (str[0] == 'B') {
    t++;
    arr[t]++;
  }
  for (int i = 1; i < n; i++) {
    if (str[i] == 'B') {
      if (str[i - 1] != 'B') {
        t++;
        arr[t]++;
      } else
        arr[t]++;
    }
  }
  cout << t << endl;
  for (int i = 1; i <= t; i++) cout << arr[i] << " ";
}
