#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  long long n;
  cin >> n;
  long long i, kol = 0;
  vector<long long> A;
  for (i = 1; i <= n; ++i) {
    char a;
    cin >> a;
    if (a == 'B')
      ++kol;
    else {
      if (kol > 0) A.push_back(kol);
      kol = 0;
    }
  }
  if (kol > 0) A.push_back(kol);
  cout << A.size() << endl;
  for (i = 0; i < A.size(); ++i) cout << A[i] << " ";
}
