#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, c = 1, d = 0, a = 0, f = 0, sum = 0, j = 0;
  cin >> n;
  string s;
  cin >> s;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'B' && s[i] == s[i + 1]) {
      c++;
    } else if (s[i] == 'B') {
      c = 1;
      j++;
    } else
      continue;
  }
  cout << j << endl;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'B' && s[i] != s[i + 1]) {
      f++;
      cout << f << " ";
    } else if (s[i] == 'B' && s[i + 1] == 'B') {
      a++;
      if (s[i + 1] != s[i + 2]) {
        cout << a + 1 << " ";
        a = 0;
        i++;
      }
    }
    f = 0;
  }
}
