#include <bits/stdc++.h>
using namespace std;
const int maxn = 110;
char str[maxn];
int a[maxn];
int main() {
  int n;
  while (~scanf("%d", &n)) {
    scanf("%s", str);
    memset(a, 0, sizeof(a));
    int tot = 0, cnt = 0;
    for (int i = 0; i < n; ++i) {
      if (str[i] == 'B') {
        if (cnt)
          ++cnt;
        else {
          ++cnt;
        }
      } else {
        if (i && cnt && str[i - 1] == 'B') a[tot++] = cnt;
        cnt = 0;
      }
    }
    if (cnt) a[tot++] = cnt;
    printf("%d\n", tot);
    if (tot) {
      printf("%d", a[0]);
      for (int i = 1; i < tot; ++i) printf(" %d", a[i]);
      printf("\n");
    }
  }
  return 0;
}
