#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string str;
  while (cin >> n >> str) {
    int cnt = 0, cnter[1001], j = 0;
    for (int i = 0; i < n + 5; i++) cnter[i] = 0;
    for (int i = 0; i < n; i++) {
      if (str[i] == 'B') {
        cnter[j] += 1;
      }
      if (str[i] == 'B' && str[i + 1] != 'B') {
        j++;
        cnt++;
      }
    }
    cout << cnt << endl;
    if (cnt == 0) continue;
    for (int k = 0; k < cnt; k++) {
      cout << cnter[k] << ' ';
    }
    return 0;
  }
}
