#include <bits/stdc++.h>
using namespace std;
long long ar[1000001], arr[1000001], a[1000001];
int main() {
  int x, sum = 0, n = 0;
  string s;
  cin >> x >> s;
  for (int i = 0; i < x; i++) {
    if (s[i] == 'B' && i != x - 1)
      sum++;
    else if (s[i] == 'B' && i == x - 1) {
      sum++;
      arr[n] = sum;
      n++;
      sum = 0;
    } else if (i > 0 && s[i] == 'W' && s[i - 1] == 'B') {
      arr[n] = sum;
      n++;
      sum = 0;
    }
  }
  int yy = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] != 0) yy = 9;
  }
  if (yy == 9) {
    cout << n << "\n";
    for (int i = 0; i < n; i++) {
      cout << arr[i] << " ";
    }
  } else
    cout << "0";
  cout << "\n";
  return 0;
}
