#include<bits/stdc++.h>

using namespace std;

int main(){
    int n, res, m;
    vector<int> r;
    string s;
    cin >> n;
    cin >>s;
    for(int i = 0; i < n; ++i){
        if(s[i] == 'B'){
            m = 0;
            while(s[i] == 'B'){
                m++;
                i++;
            }
            r.push_back(m);
        }
    }
    cout << r.size() << endl;
    for(int i = 0; i < r.size(); ++i) cout << r[i] << " ";
}