#include <bits/stdc++.h>
using namespace std;
char symmetric[11] = {'A', 'H', 'I', 'M', 'O', 'T', 'U', 'V', 'W', 'X', 'Y'};
char viowels[5] = {'a', 'e', 'i', 'o', 'u'};
bool isPrime(long long int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
bool IsPalindrome(string str) {
  if (str.empty()) return false;
  long long int i = 0;
  long long int j = str.length() - 1;
  while (i < j) {
    if (str[i] != str[j]) {
      return false;
    }
    i++;
    j--;
  }
  return true;
}
long long int binpow(long long int a, long long int b) {
  if (b == 0) return 1;
  long long int res = binpow(a, b / 2);
  if (b % 2) return (res * res * a);
  return (res * res);
}
signed main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long int n;
  cin >> n;
  string s;
  cin >> s;
  long long int c = 0;
  vector<long long int> v;
  for (long long int i = 0; i < n; i++) {
    if (s[i] == 'B') {
      c++;
      long long int k = 1;
      while (s[i] == s[i + 1] && i < n) {
        i++;
        k++;
      }
      v.push_back(k);
    }
  }
  cout << v.size() << endl;
  for (long long int i = 0; i < v.size(); i++) cout << v[i] << " ";
  return 0;
}
