tamanho = int(input())
linha = input()
anterior = ' '
atual = ' '
ehSeq = 0
seq = []
for i in range(0,tamanho):
if(i>0):
anterior = linha[i-1]
atual = linha[i]
juncAntAt = anterior+atual
if(juncAntAt == 'WB' or juncAntAt ==' B'):
seq.append(1)
elif(juncAntAt == 'BB'):
seq[len(seq)-1]+=1
print(len(seq))
print(*seq,sep=(' '))
/*
Problem: 721A
Date: 15-09-2023 05:55 AM
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <sstream>
#include <iomanip>
#include <cmath>
#define in std::cin
#define out std::cout
#define endl std::endl
#define MAX(a, b) std::max(a, b)
#define MAX3(a, b, c) std::max(a, std::max(b, c))
#define MIN(a, b) std::min(a, b)
#define MIN3(a, b, c) std::min(a, std::min(b, c))
#define MAXE(a, b) a = std::max(a, b)
#define MINE(a, b) a = std::min(a, b)
#define GETBIT(a, n) ((a >> n) & 1)
#define BITCOUNT(a) __builtin_popcount(a)
#define S std::string
#define Ss std::stringstream
#define VI std::vector<int>
#define VS std::vector<std::string>
#define MP(a, b) std::make_pair(a, b)
#define PII std::pair<int, int>
#define PSI std::pair<std::string, int>
#define PIS std::pair<int, std::string>
#define PSS std::pair<std::string, std::string>
#define SI std::set<int>
#define SS std::set<std::string>
#define SPII std::set<std::pair<int, int> >
#define SPSI std::set<std::pair<std::string, int> >
#define SPIS std::set<std::pair<int, std::string> >
#define SPSS std::set<std::pair<std::string, std::string> >
#define MSI std::multiset<int>
#define MSS std::multiset<std::string>
#define VII std::vector<int>::iterator
#define VSI std::vector<std::string>::iterator
#define SII std::set<int>::iterator
#define SPIII std::set<std::pair<int, int> >::iterator
#define SPSII std::set<std::pair<std::string, int> >::iterator
#define SPISI std::set<std::pair<int, std::string> >::iterator
#define SPSSI std::set<std::pair<std::string, std::string> >::iterator
#define MSIII std::multiset<int>::iterator
#define MSSI std::multiset<std::string>::iterator
#define MAPII std::map<int, int>
#define MAPSS std::map<std::string, std::string>
#define MAPIS std::map<int, std::string>
#define MAPSI std::map<std::string, int>
int n;
S str;
VI vec;
int main() {
in >> n >> str;
vec.push_back(0);
for(int i = 0; i < n; i++) {
if(str[i] == 'B')
vec[vec.size() - 1]++;
else if(vec[vec.size() - 1] > 0)
vec.push_back(0);
}
if(vec[vec.size() - 1] == 0)
vec.pop_back();
out << vec.size() << endl;
for(int i = 0; i < vec.size(); i++) {
out << vec[i] << " ";
}
}
115A - Party | 746B - Decoding |
1424G - Years | 1663A - Who Tested |
1073B - Vasya and Books | 195B - After Training |
455A - Boredom | 1099A - Snowball |
1651D - Nearest Excluded Points | 599A - Patrick and Shopping |
237A - Free Cash | 1615B - And It's Non-Zero |
1619E - MEX and Increments | 34B - Sale |
1436A - Reorder | 1363C - Game On Leaves |
1373C - Pluses and Minuses | 1173B - Nauuo and Chess |
318B - Strings of Power | 1625A - Ancient Civilization |
864A - Fair Game | 1663B - Mike's Sequence |
448A - Rewards | 1622A - Construct a Rectangle |
1620A - Equal or Not Equal | 1517A - Sum of 2050 |
620A - Professor GukiZ's Robot | 1342A - Road To Zero |
1520A - Do Not Be Distracted | 352A - Jeff and Digits |