#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  vector<int> s;
  int group = 0;
  string c;
  int n, k = 0;
  cin >> n;
  cin >> c;
  for (int i = 0; i <= n - 1; ++i) {
    if (c[i] == 'B') {
      k++;
      if (i == n - 1) s.push_back(k);
    } else if (c[i] == 'W') {
      if (i != 0 && c[i - 1] == 'B') {
        s.push_back(k);
        s.push_back(0);
        k = 0;
      }
      s.push_back(0);
    }
  }
  if (n > 1) {
    for (int i = 0; i <= s.size() - 1; ++i) {
      if (s[i] != 0) {
        group++;
      }
    }
    cout << group << endl;
    for (int i = 0; i <= s.size() - 1; ++i) {
      if (s[i] != 0) cout << s[i] << " ";
    }
  } else if (n == 1) {
    if (s[0] != 0) {
      cout << "1" << endl;
      cout << s[0];
    }
    if (s[0] == 0) {
      cout << "0" << endl;
    }
  }
  return 0;
}
