#include <bits/stdc++.h>
using namespace std;
int b, s = 0, v[100], j = 0;
string a;
int main() {
  cin >> b >> a;
  for (int i = 0; i < b; i++) {
    if (a[i] == 'B') {
      s++;
      v[j] = s;
      if (i == b - 1) {
        j++;
      }
    } else if (s != 0) {
      s = 0;
      j++;
    }
  }
  cout << j << endl;
  for (int i = 0; i < j; i++) {
    cout << v[i] << " ";
  }
}
