#include<bits/stdc++.h>
using namespace std;
string s;
int n;
int dp[105];
vector<int> v;
int main()
{
	cin>>n;
	cin>>s;
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=n;i++)
	{
		if(s[i-1]=='W')
		dp[i]=0;
		else
		dp[i]=dp[i-1]+1;
	}
	for(int i=1;i<=n+1;i++)
	if(dp[i]==0&&dp[i-1]!=0)
	v.push_back(dp[i-1]);
	cout<<v.size()<<endl;
	for(int i=0;i<v.size()&&v.size()!=0;i++)
	cout<<v[i]<<" ";
}

// ConsoleApplication1.cpp : Этот файл содержит функцию "main". Здесь начинается и заканчивается выполнение программы.
//

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <map>

using namespace std;

int main()
{
	int n;
	string bw;
	cin >> n;
	cin >> bw;

	int curb = 0;

	vector<int> answ;

	for (int i = 0; i < n; i++)
	{
		if (bw[i] == 'B')
			curb++;
		else
		{
			if (curb != 0)
				answ.push_back(curb);
			curb = 0;
		}
	}
	if (curb != 0)
		answ.push_back(curb);

	cout << answ.size() << endl;
	for (int i = 0; i < answ.size(); i++)
	{
		cout << answ[i] << " ";
	}

	return 0;
}

#include<bits/stdc++.h>
#include <iostream>
using namespace std;

int main() {
	// your code goes here
	int n;
	cin>>n;
	string s;
	cin>>s;
	vector<int>v;
	int c=0;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='B')
		{
			c++;
		}
		else
		{
			if(c){
			v.push_back(c);
			c=0;
			}
		}
	}
	if(c)
	v.push_back(c);
	if(v.size()==0)
	cout<<"0";
	else{
	cout<<v.size()<<endl;
	for(int i=0;i<v.size();i++)
	cout<<v[i]<<" ";
	}

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);

    string s;
    int n,j;
    cin>>n;
    cin>>s;

    for(int i=0;i<n;i++)
    {
        if(s[i]=='B')
        {
            for(j=i;j<n;j++)
            {
                if(s[j]=='W')break;
            }
            j--;
            v.push_back(j-i+1);
            i=j;
        }
    }

    cout<<v.size()<<endl;
    for(int i=0;i<v.size();i++)
    cout<<v[i]<<" ";
	return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>

using namespace std;

int main() {

    int n;
    cin >> n;
    string s;
    cin >> s;
    int ct=0;
    vector<int> appear;
    for(char x : s){
        if(x=='B'){
            ++ct;
        }
        else{
            if(ct!=0){
                appear.push_back(ct);
                ct=0;
            }
        }
    }
    if(ct!=0)appear.push_back(ct);
    cout << appear.size() << '\n';
    for(int x : appear)cout << x << ' ';
    cout << '\n';

    return 0;
}

#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<char>a;
	for (int i = 0; i < n; i++)
	{
		char temp;
		cin >> temp;
		a.push_back(temp);
	}
	vector<int>ans;
	int temp = 0;
	if(a[n-1]!='W')
	a.push_back('W');
	int temp1 = 0;
	for (int i = 0; i < n; i++)
	{
		if (a[i] == 'W')
			temp1++;
	}
	if (temp1 == n)
	{
		cout << 0;
		return 0;
	}
	if (a.size() == n + 1)
	{
		for (int i = 0; i <= n; i++)
		{
			if (a[i] == 'B')
				temp++;
			else
			{
				ans.push_back(temp);
				temp = 0;
			}
		}
	}
	if (a.size() == n)
	{
		for (int i = 0; i < n; i++)
		{
			if (a[i] == 'B')
				temp++;
			else
			{
				ans.push_back(temp);
				temp = 0;
			}
		}
	}
	int temp2 = 0;
	for (int i = 0; i < ans.size(); i++)
	{
		if (ans[i] != 0)
			temp2++;
	}
	cout << temp2 << endl;
	for (int i = 0; i < ans.size(); i++)
	{
		if(ans[i]!=0)
		cout << ans[i] << " ";
	}
	return 0;
}

#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n,sum = 0, flag = 0;
	cin >> n;
	int b[101];
	memset(b, 0, sizeof(b));
	char a[101];
	cin >> a;
	for (int i = 0; i < n; i++)
	{
		if (flag)
		{
			if (a[i] == 'B')
				b[sum - 1]++;
			if (a[i] == 'W')
				flag = 0;
		}
		else
		{
			if (a[i] == 'B')
			{
				flag = 1;
				sum++;
				b[sum - 1]++;
				continue;
			}
			if (a[i] == 'W')
				continue;
		}
	}
	cout << sum << endl;
	for (int i = 0; i < sum; i++)
		cout << b[i] << ' ';
	return 0;
}

#include <iostream>
using namespace std;
int n,c,i,ai,a[105];
string s;
int main() {
	cin>>n>>s;
	while(s[i]) {
		for(; s[i]=='W'; i++);
		for(c=0; s[i]=='B'; i++, c++);
		if(c) a[ai++] = c;
	}
	cout<<ai<<endl;
	for(i=0; i<ai; i++) cout<<a[i]<<' ';;
	return 0;
}

#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{

    unsigned int n;
    cin >> n;
    string str;
    cin >> str;

    int res=0;
    string write="";

    int cRes=0;
    char lChar='W';

    for (string::size_type i = 0; i < n; i++){

        if (lChar == 'W' && str[i] == 'B'){
            res++;
            cRes++;
        }
        else if (lChar == 'B' && str[i] == 'B'){
            cRes++;
        }
        else if (lChar == 'B' && str[i]=='W'){
            char buffer[32];
            ::sprintf(buffer, "%d", cRes);
            write.append(buffer);
            write.push_back(' ');
            cRes = 0;
        }

        lChar = str[i];

    }

    if (lChar != 'W'){
        char buffer[32];
        ::sprintf(buffer, "%d", cRes);
        write.append(buffer);
        write.push_back(' ');
    }

    cout << res << endl << write;

    return 0;
}

#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
vector <int> v;
int main()
{
    int n, ans = 0;
    cin >> n;
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == 'B'){ans++;}
        else if (ans != 0){v.push_back(ans); ans = 0;}
    }
    if (ans != 0)
    {
        v.push_back(ans);
    }

    cout << v.size() << endl;
    for (int i = 0; i < v.size(); i++){cout << v[i] << ' ';}
    cout << endl;
    return 0;
}

#include <iostream>
#include <string>

using namespace std;

int main()
{
    int ile;
    string c;

    cin>>ile;
    cin>>c;

    int ilegrup = 0;
    int grupa[ile+1];
    int cz = 0;
    for(int i = 0;i<ile;i++)
    {
        grupa[i] = 0;
       if(c[i] == 'B') cz++;
       else if(c[i] == 'W' && cz != 0)ilegrup++;
       if(c[i] == 'W') {grupa[i] = cz; cz = 0;}
    }
    if(cz != 0){grupa[ile-1] = cz;ilegrup++;}
    if(grupa != 0) cout<<ilegrup<<endl;
    for(int i = 0;i<ile;i++)
    {

        if(grupa[i] != 0)cout<<grupa[i]<<" ";
    }

}

#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <sstream>
#include <string>
#include <bitset>
#include <algorithm>
#include <set>
#include <sstream>
#include <queue>
using namespace std;

int main(){
    int n,num=0,j=0,ct=0;
    cin >> n;
    int* arr = new int[n];
    for(int x=0;x<n;x++){
        arr[x]=0;
    }
    string in;
    cin >> in;
    while((in[j] != 'B') && (j<n)){
        j++;
    }
    for(int i=j;i<n;i++){
        if(in[i] == 'B'){
            arr[num] = arr[num]+1;
        }else{
            num++;
        }
    }
    for(int b=0;b<n;b++){
        if(arr[b] > 0){
            ct++;
        }
    }
    cout << ct << endl;
    for(int k=0;k<n;k++){
        if(arr[k] > 0){
            cout << arr[k] << " ";
        }
    }
    cout << endl;
}

#include<iostream>
using namespace std;
int a[101],n,cnt,pos;
string s;
char lastWord;
main() {
       cin>>n;
       cin>>s;
       for(int i=0;i<n;i++) {
           if(s[i] == 'B' && lastWord != 'B') {
                   pos++;
                   a[pos]++;
                   cnt++;
                   lastWord = 'B';
                   }
                   else
                   if(s[i] == 'B' && lastWord == 'B') {
                   a[pos]++;
                   lastWord = 'B';
                   }
                   else {
                   lastWord = 'W';
                   }
       }
       cout<<cnt<<endl;
       for(int i=1;i<=cnt;i++)
       cout<<a[i]<<endl;
       //system("pause");
}

#include<iostream>
#include<cstring>
using namespace std;
int qvq;string s;int len,a[101],k,st,num=1,qaq;bool b;
int main()
{
	cin>>qvq;
	cin>>s;
	len=s.size();
	b=0;num=0;
	for(int i=0;i<len;i++)
	{
		if(s[i]=='B'&&i==len-1&&b==0)
		{
			b=1;
			qaq=1;
			a[++k]=1;
			num=1;
		}
		if(s[i]=='B'&&b==0)
		{
			b=1;st=i;num++;continue;

		}
		if(s[i]=='B'&&b==1)
		{
			num++;
		}
		if(s[i]=='W')
		{
			if(num)
			{
				a[++k]=num;
				num=0;
			}
		}
		if(s[i]=='B'&&i==len-1&&qaq==0)
		{
			a[++k]=num;
		}
	}
	cout<<k<<endl;
	if(k!=0)
	{
			for(int i=1;i<=k;i++)
		{
			cout<<a[i]<<" ";
		}
	}
	return 0;
}

#include<conio.h>
#include<locale>
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int count = 0, count1 = 0;
	vector<int> vec;
	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] == 'B')
		{
			count++;
		}
		while (s[i] == 'B')
		{
			count1++;
			i++;
		}
		vec.push_back(count1);
		count1 = 0;
	}
	cout << count << endl;
	for (int i = 0; i < vec.size(); i++)
	{
		if (vec[i] != 0)
		{
			cout << vec[i] << " ";
		}
	}

	//_getch();
}

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	string s;
	cin>>n>>s;
	int c=0;
	vector<int> a;
	int temp=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='W'||i==n-1){
			if(s[i]=='B')temp++;
			if(temp!=0)c++;
			a.push_back(temp);
			temp=0;
		}
		else
		{
			temp++;
		}
	}
	cout<<c<<"\n";
	for(auto i=a.begin();i!=a.end();++i){
		if(*i!=0&&c!=0)cout<<*i<<" ";
	}
	return 0;
}

#include<iostream>
#include<vector>
#include<string>
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<char>s(n);
	vector<string>ans(n);
	bool change = true;
	bool first = false;
	int it = 0;
	for (size_t i = 0; i < n; i++)
	{
		cin >> s[i];
		if (s[i] == 'B')
		{
			if (change&&i!=0&&first)
				it++;
			ans[it].append("B");
			change = false;
			first = true;
		}
		else if(!change)
		{
			change = true;
		}
	}
	it++;
	if (first)
	{
		cout << it << endl;

		for (size_t i = 0; i < it; i++)
		{
			cout << ans[i].size() << " ";
		}
	}
	else
		cout << "0";
}

#define _CRT_SECURE_NO_DEPRECATE
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef vector<int> vi;
/*--------------------------------*/
#define pb push_back
#define mp make_pair
#define INT_MIN (-2147483647 - 1) /* minimum (signed) int value  */
#define INT_MAX 2147483647       /*  maximum (signed) int value */
#define FOR(i, a, b) for (int i = int(a); i <= int(b); i++)
#define RFOR(i, a, b) for (int i = int(a); i >= int(b); i--)
#define READ freopen("input.txt", "r", stdin);
#define WRITE freopen("output.txt", "w", stdout);
#define MOD ll(1000000007)
#define PI acos(-1)
/*-------------------------------------------------------------*/

int main() {

	int n, c;
	char str[101];
	scanf("%d %s", &n, &str);
	vi res;
	FOR(i, 0, n - 1){
		c = 0;
		while (str[i] == 'B') c++, i++;
		if (c)res.pb(c);
	}

	printf("%d\n", res.size());
	FOR(i, 0, res.size() - 1) printf("%d%c", res[i], (i != res.size() - 1) ? ' ' : '\n');

	return 0;
}

#define _CRT_SECURE_NO_DEPRECATE
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef vector<int> vi;
/*--------------------------------*/
#define pb push_back
#define mp make_pair
#define INT_MIN (-2147483647 - 1) /* minimum (signed) int value  */
#define INT_MAX 2147483647       /*  maximum (signed) int value */
#define FOR(i, a, b) for (int i = int(a); i <= int(b); i++)
#define RFOR(i, a, b) for (int i = int(a); i >= int(b); i--)
#define READ freopen("input.txt", "r", stdin);
#define WRITE freopen("output.txt", "w", stdout);
#define MOD ll(1000000007)
#define PI acos(-1)
/*-------------------------------------------------------------*/

int main() {

	int n;
	char str[101];
	scanf("%d", &n);
	scanf("%s", &str);

	if (n == 1 && str[0] == 'B')printf("1\n1\n");
	else if (n == 1 && str[0] == 'W')printf("0\n");
	else{
		vi res;
		int x = 0;
		if (str[0] == 'B')x = 1;
		FOR(i, 1, n - 1){
			if (str[i - 1] == 'W' && str[i] == 'B') x = 1;
			else if (str[i - 1] == 'B' && str[i] == 'B') x++;
			else if (str[i - 1] == 'B' && str[i] == 'W') res.pb(x);

			if (str[i] == 'B' && i == n - 1) res.pb(x);
		}
		printf("%d\n", res.size());
		FOR(i, 0, res.size() - 1){
			printf("%d", res[i]);
			printf("%c", (i != res.size() - 1) ? ' ' : '\n');
		}
	}

	return 0;
}

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    char s[110];
    scanf("%s",s);
    int t[110],k=1,flag=0;
    memset(t,0,sizeof(t));
    for(int i=0; i<n; i++)
    {
        if(s[i]=='B')
        {
            t[k]++;
            flag=1;
        }
        else
        {
            if(flag)
            {
                flag=0;
                k++;
            }
        }
    }
    if(k==1&&t[k]==0)
    {
        printf("0\n");
        return 0;
    }
    if(t[k]!=0)
        printf("%d\n",k);
    else
        printf("%d\n",k-1);
    printf("%d",t[1]);
    for(int i=2;i<k;i++)
        printf(" %d",t[i]);
    if(t[k]!=0&&k!=1)
        printf(" %d",t[k]);
    printf("\n");
    return 0;
}

#include <bits/stdc++.h>
#define pb push_back
using namespace std;
int n, c;
char s[110];
vector<int>v;
int main()
{
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>s[i];
    }
    for(int i=0; i<n; i++)
    {
        if(s[i]=='B')c++;
        if(s[i]=='W' and c>0)
        {
            v.pb(c);
            c=0;
        }
    }
    if(c!=0)
    {
        v.pb(c);
            c=0;
    }
    cout<<v.size()<<endl;
    for(int i=0; i<v.size(); i++) cout<<v[i]<<" ";
}

#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define maxn 1020

using namespace std;

int a[maxn],n,m,t;
char s[maxn];

int main()
{
	scanf("%d",&n);
	scanf("%s",s);
	m=0;t=0;
	while (t<n)
	{
		while (s[t]=='B'&&t<n)
		{
			t++;a[m]++;
		}
		if (a[m]) m++;
		t++;
	}
	printf("%d\n",m);
	for (int i=0;i<m-1;i++)
	    printf("%d ",a[i]);
	if (m) printf("%d\n",a[m-1]);
	return 0;
}

#include<bits/stdc++.h>

using namespace std;

int main()
{
  int N;
  string S;

  cin >> N;
  cin >> S;

  int ret = 0;
  vector< int > ans;
  for(char& s : S) {
    if(s == 'B') {
      ++ret;
    } else if(ret > 0) {
      ans.push_back(ret);
      ret = 0;
    }
  }
  if(ret > 0) {
    ans.push_back(ret);
  }

  cout << ans.size() << endl;
  for(int& val : ans) cout << val << " ";
}

#include <iostream>

using namespace std;

int main()
{
    int n,counter=0,sum=0,x=0;
    cin>>n;
    string str;
    int arr[n];
    cin>>str;
    for(int i=0;i<n;i++){
        if((str[i]=='B'&&str[i+1]!='B')){
        counter++;
        }
        if(str[i]=='B'){
                sum++;
        }
        if(str[i+1]!='B')
        {
            arr[x]=sum;
            sum=0;
            x++;
        }

    }
    cout<<counter<<endl;

    for(int i=0;i<x;i++){
            if(arr[i]!=0){
        cout<<arr[i]<<' ';
            }

    }
    return 0;
}

#include <cstdio>
#include <cstring>
using namespace std;
#define LL long long
const int maxn=1e5+7;
const int INF=1e9+7;
char s[maxn];
int ans[maxn];
int main()
{
	int i,j,n,m,t,z;
	scanf("%d",&n);
	scanf("%s",s+1);
	int x=0;
	int xx=0;
	n=strlen(s+1);
	for(i=1;i<=n;i++)
	{
		if(s[i]=='B')
		{
			x++;
		}
		else if(s[i]=='W'&&x!=0)
		{
			ans[xx++]=x;
			x=0;
		}
	}
	if(x!=0)
	{
		ans[xx++]=x;
		x=0;
	}
	printf("%d\n",xx);
	for(i=0;i<xx;i++)
	{
		printf("%d%c",ans[i],i==xx-1?'\n':' ');
	}
	return 0;
}

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include <cmath>
	using namespace std;
int main()
{
	int n;
	cin>>n;
	int b[105]={0};
	char a[105]={0};
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int flag=0;
	int cs=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]=='B')
		{
			flag=1;
			b[cs]++;
		}
		else if(a[i]=='W' && flag==1)
		{
			cs++;
			flag=0;
		}
	}
	if(a[n-1]=='B' && flag==1)
	{
		cs++;
	}
	cout<<cs<<endl;
	for(int i=0;i<cs;i++)
	{
		cout<<b[i]<<" ";
	}
	cout<<endl;
	getchar();
	getchar();
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string s;
    cin>>n>>s;
    int ans[100];
    int tmp = 0;
    int k=0;
    for(int i=0; i<s.size(); i++)
    {
        if(s[i]=='B') tmp++;
        else
        {
            if(tmp)
                ans[k++] = tmp;
            tmp = 0;
        }
    }
    if(tmp)
        ans[k++] = tmp;
    cout<<k<<endl;
    for(int i=0;i<k;i++)
    {
        cout<<ans[i]<<" ";
    }
    cout<<endl;

    return 0;
}

#include <stdio.h>
#include <string.h>

int main()
{
	int n,k=0,i,t,w,f=0;

	scanf("%d",&n);
	char str[n+1];
	scanf("%s",str);
	int a[n];
	//char str[n+1];
	t=0;
	for (i=0;i<n;i++){
		if (str[i]=='B'){
			f=1;
			t++;
		}
		else if (str[i]=='W'){

			if (t>0){
				a[k]=t;
				k++;
			}
			t=0;
		}
	}
	if (f==0){

		printf("0");return 0;

	}
	if (t>0){
	a[k]=t;
	k++;
	}
	printf("%d\n",k);
	for (i=0;i<k;i++){
		printf("%d ",a[i]);
	}
return 0;

}

#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {

    //freopen("input.txt", "rt", stdin);

    int length;
    string crossWord;
    vector<int> results;

    cin >> length >> crossWord;

    int count = 0;
    for (int i = 0; i < length; i++) {
        if (crossWord[i] == 'B')
            count++;

        if (crossWord[i] == 'W' || i == length - 1)
        {
            if (count > 0) {
                results.push_back(count);
                count = 0;
            }
        }
    }

    cout << results.size() << endl;
    for (int i = 0; i < results.size(); i++) {
        cout << results[i] << " ";
    }

    cout << endl;

    return 0;
}

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <cstdio>
#include <vector>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <set>
#define INF 0x3f3f3f3f
#define fori(a,b) for(LL i=a;i<=b;i++)
#define forj(a,b) for(LL j=a;j<=b;j++)
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long LL;
const double PI = acos(-1);
const LL M = 1e2+10;
//const LL MM = 1e5+10;
int n,k;
struct node1 {
    int sx,sy;
    int ex,ey;
    int len;
}a[M];

int main()
{
    //freopen("//home//acm//桌面//in","r",stdin);
    int n,ans[M],p=0;
    mem(ans,0);
    string s;
    cin >> n;
    cin >> s;
    for(int i=0;i<n;i++){
        if(s[i]=='B'){
            ans[p]++;
        }
        if((s[i]=='W'&&i-1>=0&&s[i-1]=='B')||(s[i]=='B'&&i==n-1)){
            p++;
        }

    }
    cout << p <<endl;
    for(int i=0;i<p;i++)
        cout << ans[i] << " ";
    return 0;
}

#include<bits/stdc++.h>
using namespace std;

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define P(a,n) for(int i=a;i<=n;i++) cout<<a[i]<<" ";
#define bp(n) __builtin_popcount(n);
#define D 1000000007
#define pb push_back
#define ci(x) cin>>x;
#define c2(x,y) cin>>x>>y;
#define c3(x,y,z) cin>>x>>y>>z;
#define p2(x,y) cout<<x<<" "<<y<<endl;
#define p3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define co(x) cout<<x<<endl;
#define r0 return 0;
#define r1 return 1;
#define fi first
#define se second
#define mp make_pair

typedef vector<int> VI;
typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> VII;
typedef vector<ll> VL;
typedef vector<pll> VLL;
ll tpp = 9e18; int tp = 1e9;
int n;
string s;
int main()
{
	_
	ci(n);
	ci(s);
	if(s.length()==1)
	{
		if(s[0] == 'B')
		{
			co(1);
			co(1);
			r0;
		}
		else
		{
			co(0);
			r0;
		}
	}
	int z = 0;
	for(int i=0;i<s.length();i++)
		if(s[i] == 'B')
			z++;
	if(z == 0)
	{
		co(0);
		r0;
	}
	int c = 0;
	VI a;
	if(s[0] == 'B') c = 1;
	else c = 0;
	for(int i=1;i<s.length();i++)
	{
		if(s[i] == 'B')
		{
			c++;
			if(i == s.length()-1)
				a.pb(c);
		}
		else
		{
			a.pb(c);
			c = 0;
		}
	}
	z = 0;
	for(int i=0;i<a.size();i++)
		if(a[i] == 0)
			z++;
	co(a.size() - z);
	for(int i=0;i<a.size();i++)
		if(a[i] != 0)
			cout<<a[i]<<" ";
	cout<<endl;
	r0;
}

#include <iostream>
#include <string>
using namespace std;

int a[101];
int main(){
	int n;
	int iloscCzarnych = 0;
	int dlugoscCurrent = 0;
	int numerator = 0;
	char prev = 'W';
	string s;
	cin>>n>>s;
	s = s+"W";
	//cout<<s;
	for(int i = 0;i<(n+2);i++){
		if (s[i] == 'B'&&prev == 'W'){
			dlugoscCurrent = 1;
			iloscCzarnych++;
			//cout<<"pocz c"<<endl;
			}else if(s[i] == 'B' && prev == 'B'){
			dlugoscCurrent++;
			}else if(s[i] == 'W' && prev == 'B'){
			a[numerator] = dlugoscCurrent;
			numerator++;
			dlugoscCurrent = 0;
			//cout<<"kon c"<<endl;
			}
		prev = s[i];
		}
	cout<<iloscCzarnych<<endl;
	if(iloscCzarnych == 0)
		return 0;
	for(int i = 0;i<101;i++){
		if(a[i]==0)
			return 0;
		cout<<a[i]<<endl;
		}
	cout<<endl;
	}

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main(){
	int a;
	cin >> a;
	string s;
	cin >> s;
	int cnt = 0;
	vector<int>vec;
	int tot = 0;
	for (int i = 0; i < s.size();i++){
		if (s[i] == 'B')
			cnt++;
		else if(cnt != 0){
			tot++;
			vec.push_back(cnt);
			cnt = 0;
		}
		if (i == s.size() - 1 && s[i] == 'B'){
			vec.push_back(cnt);
			tot++;
		}
	}
	if (tot != 0){
		cout << tot << endl;
		for (int i = 0; i < vec.size(); i++)
			cout << vec[i] << " ";
	}
	else
		cout << "0";

}

#include <bits/stdc++.h>
/*
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <set>
#include <cmath>
#include <cstring>

#include <stdio.h>
#include <string.h>
#include <sstream>
#include <stdlib.h>
#include <vector>
#include <iomanip>
#include <ctime>
*/
#define nl "\n"
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define p_un(a) ((void)a)
#define p_st(a) string(a)
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define naj ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define NL cout << endl;
#define sqr(x) (sqrt(x) * 1LL)
#define pcnt(i) __builtin_popcount(i)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a * b) / gcd(a, b)
#define FOR(i, k, n) for(int i = k; i <= n; i++)
#define E 2.718281828459045
#define PI 3.141592653589793

using namespace std;

typedef long long llong;
typedef long double ldouble;
typedef unsigned long long ullong;
typedef vector <llong> vl;
typedef vector <bool> vb;
typedef vector <char> vc;
typedef vector <int> vi;
typedef vector <string> vs;
typedef pair <llong, llong> pll;
typedef map <llong, llong> mll;
typedef set <llong> sl;
typedef set <char> sc;
typedef map <string, llong> msl;
typedef map <string, bool> msb;
typedef map <char, llong> mcl;
typedef map <string, string> mss;

const llong MXN = 1e5 + 1;
const llong MNN = 1e3 + 1;
const llong MOD = 1e9 + 7;
const llong INF = 1e18;
const llong MAGIC = 1000;
const ldouble EPS = 1e-9;

//int dx[]= {1,0,-1,0}; int dy[]= {0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1}; int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2}; int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={-1,-1,+0,+1,+1,+0}; int dy[]={-1,+1,+2,+1,-1,-2}; //Hexagonal Direction

vector <int> v;

int main() {

	int n, ans = 0;
	cin >> n;
	string s;
	cin >> s;
	for(int i = 0; i < sz(s); i++) {
		if(s[i] == 'B') {
			int cnt = 1;
			for(int j = i + 1; j < sz(s); j++) {
			    if(j == sz(s) - 1 && s[j] == 'B') {
			    	cnt ++;
			    	i = sz(s) - 1;
			    } else {
					if(s[j] == 'B') {
						cnt ++;
					} else {
						i = j;
						break;
					}
				}
			}
			v.pb(cnt);
			ans ++;
		}
	}
	cout << ans;
	NL;
	for(auto e : v)
		cout << e << ' ';

   	return 0;
}

#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>

int n,c2;
vector<int>res;
char c;

void solve()
{
	cin>>n;
	c2=0;
	for(int i=1;i<=n;i++)
	{
		cin>>c;
		if(c=='W')
		{
			if(c2>0)res.pb(c2);
			c2=0;
		}
		else
		{
			c2++;
		}
	}
	if(c2>0)res.pb(c2);
	cout<<res.size()<<"\n";
	for(int i=0;i<res.size();i++)cout<<res[i]<<" ";
	cout<<"\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
	solve();
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,cnt=0,gps=0;
    string a;
    cin>>n>>a;
    vector<int> b;

    for(int i=0;i<a.size();i++){
        cnt=0;
        if(a[i]=='B'){
            cnt++;
            gps++;
            for(int j=(++i);j<a.size();j++){
                if(a[j]=='B'){
                    cnt++;
                    if(++i==a.size()){

                        break;
                    }
                }else{
                    break;
                }
            }
            b.push_back(cnt);
        }
    }
    if(gps==0){
        cout<<"0";
        return 0;
    }else{
        cout<<gps;
        for(int i=0;i<b.size();i++){
            cout<<"\n"<<b[i];
        }
    }

}

#define _CRT_SECURE_NO_WARNINGS

#include <cmath>
#include <cstdio>
#include <iostream>
#include <algorithm>>

#include <vector>
#include <string>
#include <set>
#include <map>

#include <queue>
#include <stack>

using namespace std;

#define ABS(a) (((a) < (0)) ? (-(a)) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))

#define INF 1000000000

typedef long long int lint;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	string s;
	int a = 0;
	int n;
	cin >> n >> s;
	vector <int> answer;

	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == 'B')
			a++;
		if (s[i] == 'W')
			if (a != 0)
			{
				answer.push_back(a);
				a = 0;
			}
	}

	if (a != 0)
	{
		answer.push_back(a);
		a = 0;
	}

	printf("%d\n", answer.size());

	for (int i = 0; i < answer.size(); i++)
		printf("%d ", answer[i]);

	return 0;
}

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,i,b=0,w=0,f=0,c=0;cin>>n;string s;cin>>s;
    vector<int>v;
    s=s+'F';
    for(i=0;i<=n;i=i+1)
    {
        if(s[i]=='B')
        {
            b=b+1;
            f=1;
        }
        else
        {
            if(f==1)
            {
                v.push_back(b);
                c=c+1;
            }
            b=0;f=0;
        }
    }
    if(v.size()==0){cout<<0<<endl;}
    else
    {
        cout<<c<<endl;
        for(i=0;i<v.size();i=i+1){cout<<v[i]<<" ";}
    }
}

#include <iostream >
#include <string>
using namespace std  ;
int main ()
{
	int numOfbloks ,count=0 , counter=0,num,counters=-1 ;
	bool x = false ;
	int arr[1030] ;
	cin >> numOfbloks  ;
	string input ;
	cin >> input ;
	num=input.length() ;
	for (int i = 0; i <num; i++)
	{

		if (input[i]=='B')
		{
			count++;
			x=true ;
		}
		if (input[i]=='W'&&x==true)
		{
			if (count==0)
			{
			x=false ;
			count++;
			}
			else
			{
				x=false ;
				counters++ ;
				arr[counters] = counter ;
			}
			counter=0 ;
		}
		else if (input[i]=='W'&& x!=true)
		{
			x=false ;
			count++ ;
		}
		if (x==true)
		{
			counter++ ;
			if (i==num-1)
			{
				x=false ;
				counters++ ;
				arr[counters] = counter ;
			}
		}
	}
	if (counters==-1)
	{
	cout << 0 <<endl ;

	}
	else
	{
		cout << counters+1 << endl ;
		for (int i = 0; i < counters+1; i++)
		{
			cout<<arr[i] << endl ;
		}
	}

}

#include <iostream>
#include <string>

using namespace std;

int main()
{
	int f = 0;
	int g = 0;
	int n = 0;
	cin >> n;
	string a;
	cin >> a;
	a += "W";
	int h[n + 1];
	for (int i = 0; i < n + 1; i++)
	{
		h[i] = 0;
	}
	for (int i = 0; i < n + 1; i++)
	{
		if (a[i] == 'B')
		{
			g += 1;
		}
		else
		{
			if (g != 0)
			{
				h[i] = g;
				g = 0;
				f += 1;
			}
		}
	}
	cout << f << endl;
	for (int i = 0; i < n + 1; i++)
	{
		if (h[i] != 0)
		{
			cout << h[i] << " ";
		}
	}
	return 0;
}

    #include <iostream>
    #include <string.h>
    #include <vector>
    using namespace std;
    vector<int> v;
    int main()
    {
    	int n,ans=0;
    	string s;
    	cin >> n >> s;
    	int co=0;
    	for (int i=0;i<s.size();i++)
    	{
    		if (s[i]=='W')
    		{
    			if (co)
    			{
    				ans++;
    				v.push_back(co);
    			}
    			co=0;
    		}
    		else
    		co++;
    	}
    	if (co)
    	{
    		ans++;
    		v.push_back(co);
    	}
    	cout << ans << endl;
    	for (int i=0;i<v.size();i++)
    	cout << v[i] << ' ';
    }

#include <iostream>
#include <string>
#include <sstream>

using namespace std;

void main() {
	int i , howMany = 0 , begin =0;
	string x;

	cin >> i >> x;

	if (x.at(0) == 'B') howMany++;

	int result = x.find("WB" , 0);
	while (result != -1) {
		howMany++;
		result = x.find("WB" , ++result);
	}

	if (howMany == 0) {
		cout << 0;
		// system("pause");
		return;
	}

	bool counting;
	int cur = 0;
	string fin = "";
	x.append("W");

	for (int n=0 ;n <= i; n++){
		if (x.at(n) == 'B') counting = 1;
		else {
			counting = 0;
		}
		if (counting) cur ++;
		else if (cur != 0 && counting != 1) {
			//fin.append(to_string(cur) + " ");
			stringstream k;
			k << cur;
			fin.append(k.str() + " ");
			cur = 0;
		}
	}

	cout << howMany << endl;
	fin.assign(fin , 0 , fin.size() - 1);
	cout << fin;
}

#include <iostream>

using namespace std;
string perevod(int i)
{
    int x=i;
    string res;
    while(x>9){
        res=char(x%10+48)+res;
        x=x/10;
    }
    res=char(x+48)+res;
    return res;
}

int main()
{
    int n;
    cin>>n;
    string s;
    int x=0;
    int k=0;
    string res="";
    for (int i=1; i<=n; i++){
        char ch;
        cin>>ch;
        if (int(ch)==66) x++; else {
            if (x!=0){
                res+=perevod(x);
                res+=' ';
                x=0;
                k++;
            }
        }
    }
    if (x!=0) {
        k++;
        res+=perevod(x);
    }
    cout<<k<<endl<<res;
}

#include<iostream>
#include<vector>

using namespace std;

int main()
{
	vector<int>a(100);
	int n,cnt=0;
	cin>>n;

	char c[n];
	for(int i=0;i<n;i++)
		cin>>c[i];
	int k=0;

	for(int i=0;i<n;i++)
	{
		a[k]=0;

		if(c[i]=='B')
		{
			while(c[i]!='W' && i<n)
			{
				a[k]++;
				i++;
			}

			k++;
		}
	}

	cout<<k<<endl;

	for(int i=0;i<k;i++)
		cout<<a[i]<<" ";

	return 0;

}

#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
char a[110];
int  p[113];
int main()
{
	int n,i,len;
	scanf("%d",&n);
	scanf("%s",a);
	len  = strlen(a);
	int cnt = 0,flag = 0,con = 0;
	memset(p,0,sizeof(p));

	for(i = 0; i< len ;i++ )
	{
		if(a[i]=='B' && con==0){
			flag = 1;
			p[cnt]++;
			con++;
		}
		else if(a[i]=='B' && con!=0){
			p[cnt]++;
		}
		else if(a[i]!='B'){
			con=0;
			cnt++;
		}
	}
	if(a[len - 1]=='B')cnt++;

	if(flag){
		int ans = 0;
		for(i = 0;i < cnt;++i)
			if(p[i]>0)ans++;
		printf("%d\n",ans);
		for(i = 0;i < cnt - 1;++i)
			if(p[i]>0)printf("%d ",p[i]);
		if(p[cnt-1]>0)printf("%d\n",p[cnt-1]);
	}
	else printf("0\n");
	return 0;
}

#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main(){
    vector<int> vec;
    int n;
    cin>>n;
    string str;
    cin>>str;
    char c='B';
    int len=0;
    for (int i=0;i<str.length();i++){
        if (str[i]==c && c=='B')
            len++;
        else{
            if (len)
                vec.push_back(len);
            len=0;
        }
    }
    if (len)
        vec.push_back(len);
    cout<<vec.size()<<endl;
    for (int i=0;i<vec.size();i++)
        cout<<vec[i]<<" ";
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

using vi = vector<int>;
#define pb push_back
#define pp pop_back

using pi = pair<int,int>;
#define f first
#define s second
#define mp make_pair
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()

int main(){

int n;
string s;
cin>>n>>s;

int ans=0;
vi v;
int t=0;

for(int i=0; i<s.size(); i++){
    if(s[i]=='B')t++;
	else
	{
		if(t!=0){
		ans++;
		v.pb(t);
		t=0;
		}
	}
}

if(t!=0)
{
	ans++;
	v.pb(t);
}

cout << v.size() << endl;

for(int i=0; i<v.size(); i++){
    cout << v[i] << " ";
}

}

#include<bits/stdc++.h>
using namespace std;
string s;
vector<long long> a;
long long t,j=0;
main()
{
    cin>>t>>s;
    for(long long i=0; i<t; i++)
    {
        if(s[i]=='W')
        continue;
        j=i;
        while(j<t&&s[j]=='B')
        j++;
        a.push_back(j-i);
        i=j-1;
    }
    cout<<a.size()<<'\n';
    for(long long i=0; i<a.size(); i++)
        cout<<a[i]<<" ";
}

//#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <stdlib.h>
#include <vector>
using namespace std;
int main(){
	int n;
	scanf("%d\n",&n);
	char a[n];
	gets(a);
	vector<int> ans;
	int x=0;
	for(int i=0; i<n; i++){
		if(a[i]=='B'){
			x++;
		}else{
			if(x!=0){
				ans.push_back(x);
			}
			x=0;
		}
	}
	if(x!=0){
		ans.push_back(x);
	}
	printf("%d\n",ans.size());
	for(int i=0; i<ans.size(); i++){
		printf("%d ",ans[i]);
	}
	return 0;
}

#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <cstdlib>
const double pi = acos(-1);
using namespace std;

int main() {
	int sz, cnt = 0;
	string str;
	cin >> sz >> str;
	vector <int>ans;
	for(int i = 0; i < sz; i++)
	{
		if(str[i] == 'B')
			cnt++;
		else
		{
			if(cnt)
				ans.push_back(cnt);
			cnt = 0;
		}
	}
	if(cnt)
		ans.push_back(cnt);
	cout << ans.size() << endl;
	for(int i = 0, len = ans.size(); i < len; i++)
	{
		cout << ans[i] << ' ';
	}
	return 0;
}

/*bpx3*/
#include<stdio.h>
#include<cstring>

using namespace std;

int n,ans[105],cur;
char s[105];

int main()
{
	int i,j;
	scanf("%d",&n);
	scanf("%s",s+1);
	s[0]='W';
	s[n+1]='W';
	memset(ans,0,sizeof ans);
	cur=0;
	for(i=0;i<n+2;i++)
		if(s[i]=='B') ans[cur]++;
		else if(i>0&&s[i-1]=='B') cur++;
	printf("%d\n",cur);
	for(i=0;i<cur;i++)
		printf("%d%c",ans[i],i==cur-1?'\n':' ');
	return 0;
}

#include "bits/stdc++.h"
using namespace std;

int main()
{
    int N;
    cin >> N;
    string str;
    cin >> str;
    int Count = 0;
    for(int i = 0; i < str.length(); i++)
    {
        if(str[i] == 'B' && str[i+1] != 'B')
            Count++;
    }
    if(Count == 0)
    {
        cout << 0 << endl;
        return 0;
    }
    cout << Count << endl;
    int Space = 0;
    for(int i = 0; i < str.length(); i++)
    {
        if(str[i] == 'B')
        {
            int temp = 0;
            while(str[i] == 'B')
            {
                temp++;
                i++;
            }
            if(Space > 0)
                cout << ' ';
            cout << temp;
            Space++;
        }
    }
    cout << endl;
}

#include <bits/stdc++.h>
using namespace std;
int main ()
{
    int sq, black = 0, k = 0;
    cin >> sq;
    vector <int> sqNums;
    char r[sq];
    for (int i = 0; i < sq; i++)
    cin >> r[i];
    if (r[sq - 1] == 'B')
    k++;
    for (int i = 0; i < sq; i++)
    {
        if (r[i] == 'B')
        black++;
        if (r[i] == 'B' && r[i + 1] == 'W')
        {
            k++;
            sqNums.push_back(black);
            black = 0;
        }
    }
    sqNums.push_back(black);
    cout << k << "\n";
    for (int i = 0; i < k; i++)
    cout << sqNums[i] << " ";
    return 0;
}

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<vector>
#include<iostream>
using namespace std;
typedef long long  LL;
const double pi=acos(-1.0);
const double e=exp(1);
//const int MAXN =2e5+10;
const int N =332748118;

int con[109];

int main()
{
	int i,p,j,n,t;
	int len = 0,times = 0;
	char c;
	memset(con,0,sizeof(con));
	scanf("%d",&n);
	getchar();
	for(i = 1; i <= n; i++)
	{
		scanf("%c",&c);
		if(c == 'B')
		{
			len ++;
		}
		else if(c != 'B' && len > 0)
		{
			times++;
			con[times] = len;
			len = 0;
		}
		else
		{
            len = 0;
		}
	}
	if(len != 0)
	{
		times ++;
		con[times] = len;
	}

	printf("%d\n", times);
	if(times >= 1)
        printf("%d", con[1]);
	for(i = 2; i <= times; i++)
	{
		printf(" %d", con[i]);
	}
	return 0;
}

#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <cstdio>
#include <math.h>
#include <list>
#include <map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define For0(i,n) for(int i=0;i<(int)n;i++)
#define For1(i,n) for(int i=1;i<=(int)n;i++)
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

int main()
{
	int n;

	cin >> n;

	string s;

	cin >> s;
	int ans[100],l=1;
	memset(ans, 0, sizeof(ans));
	for(int i=0;i<n;i++){
		if(s[i] == 'B'){
			ans[l]++;
			//cout <<ans[l] <<endl;
		}else if(s[i+1] == 'B' && s[i]=='W' && ans[l] > 0){
			l++;
		}
	}
	if(ans[1] > 0)
	 cout << l <<endl;

	for(int i=1;i<=l;i++){
		cout << ans[i];

		if(i <l){
			cout << " ";
		}
	}
	cout << endl;

	return 0;
}

#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int B[100] = { 0 }, n, j = 0; cin >> n;
	bool flag = false;
	char c;

	for (int i = 0; i < n; ++i)
	{
		cin >> c;

		if (c == 'B')
		{
			B[j]++;
			flag = true;
		}
		else
			if (flag)
			{
				j++;
				flag = false;
			}
	}

	if (flag)
	{
		j++;
		flag = false;
	}

	cout << j << endl;

	for (int i = 0; i < j; ++i)
		cout << B[i] << " ";
}

#include<iostream>
#include<cstdio>
using namespace std;
int n,sum,ans;
string s;
int main()
{
	cin>>n;
	cin>>s;
	for(int i=0; i<n; i++)
	{
		if(s[i]=='B') sum++;
		else if(s[i-1]=='B') ans++,sum=0;
	}
	if(sum!=0) ans++;
	cout<<ans<<endl;
	sum=0;
	for(int i=0; i<n; i++)
	{
		if(s[i]=='B') sum++;
		else if(s[i-1]=='B') cout<<sum<<" ",sum=0;
	}
	if(sum!=0) cout<<sum<<endl;
	return 0;
}

#include <iostream>

using namespace std;

int main()
{
	int B[100] = { 0 }, n, j = 0, flag = 0; cin >> n;
	char c;

	while (cin >> c)
		if (c == 'B')
		{
			B[j]++;
			flag = 1;
		}
		else if (flag) { j++; flag = 0; }

	if (flag) j++;

	cout << j << endl;

	for (int i = 0; i < j; ++i)
		cout << B[i] << " ";
}

#include<iostream>
#include<cmath>
#include<string>
#include<stack>
#include<algorithm>
using namespace std;
int main()
{

	int n,G=0,E=0,e=0;
	cin >> n;
	string s;
	cin >> s;

	for (size_t i = 0; i < n; i++)
	{
		if (s[i]=='B'&& s[i+1]!='B')
		{
			G++;
		}

	}

	cout << G << endl;

	for (size_t i = 0; i < n; i++)
	{
		if (s[i]=='B'&& s[i+1]=='B')
		{
			E++;

		}

		if (s[i] == 'B'&& s[i + 1] != 'B')
		{
			cout << E + 1<<" ";
			E = 0;
		}

		/*if (s[n-1]=='B'&&s[n-2]=='W')
		{
			cout << "1" << endl;
			break;
		}
		*/

	}

	return 0;
}

#include<bits/stdc++.h>
using namespace std;

/////
//For PBDS
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define orderfind       find_by_order
#define orderkey        order_of_key

//////
#define ll 		long long int
#define ld		long double
#define pll		pair <ll,ll>
#define vl		vector <ll>
#define vb		vector <bool>
#define	vpll		vector <pair <ll,ll> >
#define pb		push_back
#define ff		first
#define ss		second
#define present(c,x)    ((c).find(x) != (c).end())
#define cpresent(c,x)   (find(all(c),x) != (c).end())
#define all(c)		c.begin(),c.end()
#define uniq(c)         (c).resize(distance((c).begin(), unique(all(c))))
#define minel(a)	*min_element(all(a))
#define maxel(a)	*max_element(all(a))
#define qu(t)		queue < t >
#define st(t)		stack < t >
#define Set		set <ll>
#define desc_Set	set <ll, greater <ll> >
#define min_pq(dt)      priority_queue < dt, vector < dt >, greater < dt > >
#define max_pq(dt)      priority_queue < dt >
#define fastio 		ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR(i,a,b)	for(ll i= (a); i <= (b) ; i++)
#define FORD(i,a,b)	for(ll i = (a); i >= (b); i--)

//////
const int INT = 1e9;
const ll LINF = 1e18;
const ll mod = 1e9+7;

//////
ll mod_sum() { return 0LL; }
template<typename T, typename... Args>
T mod_sum(T a, Args... args) { return ((a + mod_sum(args...))%mod + mod)%mod; }

ll mod_prod() { return 1LL; }
template<typename T, typename... Args>
T mod_prod(T a, Args... args) { return (a*mod_prod(args...))%mod; }

/////
ll pow(ll a, ll b, ll md = mod);
ll inv(ll a, ll m = mod);
void man_seive(ll N);
vl isprime(1e7+5 , true);	//checks if no is prime
vl prime;			//stores all primes
vl SPF(1e7+5);			//stores smallest prime factor

/////
int main(void)
{
	fastio;
	int t = 1;
//	cin>>t;
	while(t--)
	{
		ll n,temp=1;
		cin>>n;
		string str;
		cin>>str;
		if(n == 1)
		{
			if(str[0] == 'B')
				cout<<"1\n1";
			else
				cout<<"0";
			return 0;
		}
		vl ans;
		FOR(i,0,n-2)
		{
			if(str[i] == 'B' && str[i+1] == 'B')
			{
				temp++;
			}
			else if(str[i] == 'W')
				continue;
			else
			{
				ans.pb(temp);
				temp = 1;
			}
		}
		if(str[n-1] == 'B' && n >1 && str[n-2] == 'W')
			ans.pb(1);
		else if(str[n-1] == 'B' && n > 1 && str[n-2] == 'B')
			ans.pb(temp);
		cout<<ans.size()<<endl;
		if(ans.size() != 0)
		FOR(i,0,ans.size()-1)
			cout<<ans[i]<<" ";
	}
	return 0;
}

/////
void man_seive(ll N)
{
        isprime[0] = isprime[1] = false ;
        for (ll i=2; i<N ; i++)
        {
                if (isprime[i])
                {
                        prime.push_back(i);
                        SPF[i] = i;
                }
                for (ll j=0; j < prime.size() && i*prime[j] < N && prime[j] <= SPF[i]; j++)
                {
                        isprime[i*prime[j]]=false;
                        SPF[i*prime[j]] = prime[j];
                }
        }
        return;
}

ll pow(ll a, ll b, ll md)
{
	ll res = 1;
	while(b > 0)
	{
		if(b&1)
		{
			res *= a;
			res %= md;
		}
		a *= a;
		a %= md;
		b >>=  1;
	}
	return res;
}

ll inv(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }

    if (x < 0)
       x += m0;

    return x;
}

#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define reg register
#define in cin>>
#define out cout<<
#define end return 0
#define ios ios_base::sync_with_stdio(false)
using namespace std;
int main(){
    ios;
    reg int n;
    in n;
    char a[n];
    in a;
    reg int ans=0,s=0;
    reg int k[101]={0},k_zz=0;
    for(reg int i=0;i<n;i++){
    	if(a[i]=='B'){
    		if(s==0)ans++;
    		s++;
    		if(i==n-1&&s!=0){
				k[k_zz]=s;
				break;
			}
    	}
    	else{
    		if(s!=0){
    			k[k_zz]=s;
    			k_zz++;
    		}
    		s=0;
    	}
    }
    out ans<<endl;
    for(reg int i=0;k[i]!=0;i++){
    	out k[i]<<" ";
    }
    end;
}

//shara's here
//SPEEEEEEEEEED IS KEEEEEEEEEEY
//REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEAAAAAAAAAAAAAAAAAAAADDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
#include <bits/stdc++.h>
using namespace std;
typedef string s;
typedef long long ll;
typedef long double ld;
const ll INF = 1e18 + 10;
const ll MINF = -(1e18 + 10);
const ll MOD = 1e9 + 7;
#if !defined(ONLINE_JUDGE)
#include "C:\debug.hpp"
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define pb push_back
#define all(x) x.begin(),x.end()
#define vl vector<ll>
#define vll vector<vector<ll> >
#define ins insert
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
int main(){
    speed;
    ll n;
    cin >> n;
    s ss;
    cin >> ss;
    ll cnt=0,bs=0;
    for( ll i=0 ; i < n-1 ; i++ ){
        if(ss[i]=='B')bs++;
        if(ss[i]=='B'&&ss[i+1]!='B')cnt++;
    }
    if(ss[n-1]=='B'){cnt++; bs++;}
    cout << cnt << endl;
    if(bs==0)return 0;
    cnt=0;
    for( ll i=0;i<n;i++){
        if(ss[i]=='B')cnt++;
        else{
        if(cnt==0)continue;
        else {cout << cnt << ' '; cnt=0;}
        }
    }
    if(cnt==0)return 0;
    else cout << cnt << endl;

return 0;}
/*
███████████████████████████████████████████████████
███████████████████████████████████████████████████
██████████████████████████████████▀████████████████
██████████████████████████████████░▀███████████████
██████████████████████████████▌███░░░▀▀████████████
██▀████████████████████▐██████░▐██░░░░░░▀▀█████████
██░████████████████████▐█████▌░██▌▄░░░░▄▄░▄████▀███
█▌░███████████████████▀░█████░░░█░░░▄████░░███▀▐███
█▌░▐██████████████████░░████▌░░░▀░░▀███▀▀░▐███▄████
██░▀██████████████▌▐█▐▄▄████▌░░░░░░░░░░░░░▌████████
███░███████████████▀░▄▄██▀█▐░░░░░░░░░░░░░░▐████████
███▄░██████████████▄░░░░░░▀▀▀░░░░░░░░░░░░░█▐███████
████▄░██████████████████▄▄▄▄▄▄▐▄░░░░░░░░░░░████████
█████▄█████████████████▀▀▀▀▀▀░░░░░░░░░░░░░░████████
████████████████████████▄░░░░░░░░░░░░░░░▄░░████████
██████████████████████████▄▄▄░░░░░░░░░▄█░▄█████████
████████████████████████████████▄░░░░██▄███▀░░▀████
█████████████████████████████▀█████▄███▀▀▀░░▄▄░████
████████████████████████████▀░░▀░░▀▀░░░░▄▄▄██▀░░▀▀█
███████████████████████████▌░░░░░░░░░░░███████░░░▄█
███████████████▄░▀████████▀░░░░░░▀░░░░███████▌░░░██
███▄▄████████████▄░▀██████▄░░░░░█░░░░████████░░░▀▀
░▀█████████████████▄░▀█████░░░░██░░░░▀██████░░░░░▄█
▐█▄▀█████████████████▄░▀████░░░██▌░░░▐████▀░░░░▄███
▐███▄▀▀█████████████████▄░▀▀░░░░▀██▌▄█▀▀░░░▄▄██████
▀▀▀▀▀░░░▀▀▀▀▀░░░▀▀▀▀▀▀▀▀▀▀▀░░░░░░░▀▀░░░░░░▀▀▀▀▀▀▀▀▀
*/

#include<bits/stdc++.h>
using namespace std;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
	int n;char c;
	int cnt=0;
	int t[100];
	memset(t,0,sizeof(t));
	bool f=0;
	cin>>n;
	while (cin>>c){
		if (c=='B'){
			if (f==0){f=1;cnt++;}
			t[cnt-1]++;
		}
		else if (c=='W') f=0;
	}
	cout<<cnt<<endl;
	for (int i=0;i<cnt;i++)
		cout<<t[i]<<" ";
}

#include <bits/stdc++.h>
#include <map>

using namespace std;
int arre[106];
int main()
{
    int n;
    cin>>n;
    string cadena;
    cin>>cadena;
    int to=0;
    int pos=0;
    int ve=0;
    for(int i=0; i<n; i++)
    {
        if(cadena[i]=='W')
        {
            ve=1;
            break;
        }
    }
    if(ve==1)
    {
    for(int i=0; i<cadena.size(); i++)
    {
        int b=0;
        for(int k=i; k<cadena.size(); k++)
        {
            if(cadena[k]=='B')
            {
                b++;
            }
            if(k==cadena.size()-1)
            {
                if(cadena[k]=='B')
                {
                    arre[pos]=b;
                    to++;
                    pos++;
                    i=k;
                }
            }
            if(cadena[k]=='W' && cadena[k-1]=='B'&& k-1>=0)
            {
                arre[pos]=b;
                pos++;
                to++;
                i=k;
                break;
            }

        }
    }
    cout<<to<<endl;
    for(int i=0; i<106; i++)
    {
        if(arre[i]>0)
        {
            cout<<arre[i]<<" ";
        }
    }
    }
    else
    {
        cout<<1<<endl;
        cout<<n<<endl;
    }

    return 0;
}

#include<bits/stdc++.h>
#include <iostream>

using namespace std;

int main()
{
int n;
vector<int> v;
string s;
cin>>n>>s;
int c=0,c1=0;
for(int i=0;i<s.length();i++)
{
    if(s[i]=='B' && (s[i+1]=='W' || s[i+1]=='\0'))
    {  c1++;
        v.push_back(c1);
        c++;
        c1=0;
    }
    else if(s[i]=='B')
    {
        c1++;
    }
}
cout<<c<<endl;
for(auto x:v)
cout<<x<<" ";
cout<<endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
    ll n;
    cin >> n;
    char s[n + 1];
    ll kolb = 0;
    for (ll i = 0; i < n; ++i) {
        cin >> s[i];
        if ((s[i] == 'B') && not(i)) ++kolb;
        else {
            if ((s[i] == 'B') && (i) && (s[i - 1] != 'B')) ++kolb;
        }
    }
    cout << kolb << endl;
    ll vr = 0;
    s[n] = 'z';
    for (ll i = 0; i <= n; ++i) {
        if (s[i] == 'B') ++ vr;
        if ((s[i] != 'B') && (vr)) {
            cout << vr << " ";
            vr = 0;
        }
    }
}

#include<iostream>
#include<string>
#include<vector>
using namespace std;

int main() {
	int n;
	cin >> n;
	string str;
	cin >> str;
	int len=str.length();
	vector<int> v;
	int count=0;

	for(int i=0;i<len;++i){
	   if(str[i]=='B')
	        ++count;
	   else if(str[i]=='W'&&count!=0){
	       v.push_back(count);
	       count=0;
	   }
	}
	if(count!=0)
	    v.push_back(count);
	len=v.size();
	cout << len << '\n';
	for(int i=0;i<len;++i)
	    cout << v[i] << ' ';

	return 0;
}

#include <bits/stdc++.h>
using namespace std;

bool comp (string a , string b)
{
    return (a.size() < b.size());
}

int main() {

    int n;
    cin >> n;
    string z;
    cin >> z;
    vector <int> v;
    string h = "";
    int s = 0 ;
    int k = 0;
    for (int i = 0 ; i < n  ; i++)
    {
        if (z[i] == 'W')
        {
            v.push_back(i);
        }
    }
    if (z[0] !='W')
    {
        v.insert(v.begin() , -1);
    }
       if (z[z.size() - 1] !='W')
    {
        v.push_back(n);
    }
    vector <int> r;
    for (int i = 1 ; i < v.size() ; i++)
        if (v[i] - v[ i - 1] - 1)
        r.push_back(v[i] - v[i - 1] - 1);

    cout << r.size() << endl;
    for (int i = 0 ; i < r.size() ; i++)
        cout << r[i] << endl;
}

//-- In the name of ALLAH --
#include<bits/stdc++.h>
using namespace std;

#define      mod     1e9+7
#define      pai     acos(-1)
#define      ff      first
#define      ss      second
#define      ll      long long
#define      pb      push_back
#define      mp      make_pair
#define      endl    "\n"
#define      all(v)  v.begin(),v.end()
#define      fii     freopen("input.txt","r",stdin);
#define      foo     freopen("output.txt","w",stdout);
#define      fast    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

const ll mx = 1e5+10;

int main()
{
    ll i,j,a,b,c,d,n,m,t;
    string s;
    cin>>n>>s;
    vector<ll>vec;
    ll cnt=0;
    for(auto ch:s)
    {
        if(ch=='B')
        {
            cnt++;
        }
        else
        {
            if(cnt)
            {
                vec.pb(cnt);
            }
            cnt=0;
        }
    }
    if(cnt)
    {
        vec.pb(cnt);
    }
    cout<<vec.size()<<endl;
    for(auto it:vec)
    {
        cout<<it<<" ";
    }
    if(vec.size())
    {
        cout<<endl;
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int i,n,cal=0,a[4],c=0;
  cin>>n;
  string s;
  cin>>s;
  vector<int> v;
  for(i=0;i<n;i++)
  {
    if(s[i]=='B')
    c++;
    else
    {
      if(c!=0)
      v.push_back(c);
      c=0;
    }
  }
  if(c!=0)
  v.push_back(c);
  cout<<v.size()<<"\n";
  for(i=0;i<v.size();i++)
  {
    cout<<v[i]<<"\n";
  }
  return 0;
}

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <queue>
#define MAX 987654321
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    string s;
    vector<int> ans;
    cin >> s;
    if(s[0]=='B') ans.push_back(1);
    for(int i=1;i<n;i++){
        if(s[i-1]=='B'&&s[i]=='B'){
            ans.back() += 1;
        }
        else if(s[i-1]=='W'&&s[i]=='B'){
            ans.push_back(1);
        }
        else{
            continue;
        }
    }
    cout << ans.size() << endl;
    for(int i=0;i<ans.size();i++){
        cout<< ans[i]<<" ";
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string s;
	int i,count=0,l;
	cin>>s;
	vector <int> v;
	for(i=0;i<n;i++)
	{

		if(s[i]=='B')
		{count=count+1;
		}
		else
		{if(count!=0)
		{v.push_back(count);
		}
		count=0;
		}

	}
	if(count!=0)
	{v.push_back(count);
	}
	l=v.size();
	cout<<l<<endl;
	for(i=0;i<l;i++)
	{cout<<v[i]<<" ";
	}
}

#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
#include<cctype>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
using namespace std;
vector<int>counts;
int main()
{
	int n;
	scanf("%d",&n);
	string s;
	cin >>s;
	int c=0;
	for(int i=0;i<n;i++){
		if(s[i]=='B')
			c++;
		else{
			if(c>0)
			counts.push_back(c);
			c=0;
		}
	}
	if(s[n-1]=='B')
		counts.push_back(c);
	printf("%d\n",counts.size());
	for(int i=0;i<counts.size();i++){
		cout <<counts[i]<<" ";
		if(i==counts.size()-1)
			cout <<endl;
	}
	return 0;
}

#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,a[105],tot;
string s;
int main(void){
    cin>>n>>s;
    for(ll i=0; i<n; i++){
        if(s[i]=='B'&&(s[i-1]!='B'||i==0)) a[++tot]=1;
        else if(s[i]=='B'&&s[i-1]=='B'&&i!=0) a[tot]++;
    }
    printf("%lld\n",tot);
    for(ll i=1; i<=tot; i++) printf("%lld ",a[i]);
    puts("\r");
}

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#define MP make_pair
#define PB push_back
#define AC int
#define AK main
const int mod = 1e9 + 7;
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const int maxm = 2e6 + 5;
int n;
string s;
int cnt[105];
int top=1;
AC AK(){
	cin>>n>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='B'){
			if(s[i-1]=='B'){
				++cnt[top-1];
			}
			else{
				++cnt[top++];
			}
		}
	}
	cout<<top-1<<endl;

	if(top!=1){
	   // cout<<"**";
	    for(int i=1;i<top-1;i++)cout<<cnt[i]<<' ';
    	cout<<cnt[top-1]<<endl;
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int ans[105];
int main(){
    int n;
    string s;
    cin>>n>>s;
    int cnt1=0,cnt2=0;
    if(s[0]=='B'){
        cnt2++;
    }
    for(int i=1;i<n;i++){
        if(s[i]=='B'){
            cnt2++;
        }
        else if(cnt2>0){
            ans[cnt1]=cnt2;
            if(s[i-1]=='B')cnt1++;
            cnt2=0;
        }
    }
    if(cnt2>0)ans[cnt1++]=cnt2;
    cnt2=0;
    cout<<cnt1<<endl;
    for(int i=0;i<cnt1;i++)cout<<ans[i]<<' ';
    return 0;
}

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <deque>
#include <math.h>
#include <cstring>
#include <string.h>
#include <stdlib.h>
using namespace std ;
#define ll long long
//XDZ --> by Mr.X ;
int n ;
void FastInputOutput(){
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

int main (){
    FastInputOutput() ;
    vector <int> a ;
    int counter=0;
    string s ;
    cin >> n;
    cin >> s;
    for (int i=0; i<n; i++){
        if(s[i]== 'B')
            counter ++;
        if(s[i]=='W' && counter != 0 ){
            a.push_back(counter);
            counter = 0 ;
        }
    }
    if ( counter != 0 )
        a.push_back( counter ) ;
    cout << a.size() << endl ;
    for(int i =0; i<a.size(); i++)
        cout << a[i] << " ";
    return 0 ;
}

#include <iostream>
using namespace std;
int p[102];
int main()
{
	int k, hat=0, mej=0, j=0, l=1, f=0;
	char a[102];
	cin>>k;
	for(int i=0; i<k; i++)
		cin>>a[i];
	for(j=0; j<k; j+=l)
	{
		if(a[j]=='B')
		{
			hat++;
			for( ; ; l++)
				{
					if(j+l>k)
						break;
					if(a[j+l]==a[j+l-1])
									p[f]++;
								else
								{
									f++;
									break;
								}
			}
		}
		else
		{
			l=1;
			continue;
		}
		}
		cout<<hat<<endl;
		for(int o=0; o<f; o++)
			cout<<p[o]+1<<" ";
	return 0;
}

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;

const int maxn=205;

int n;
char s[maxn];
int a[maxn];
int cnt;

int main()
{
	scanf("%d",&n);
	scanf("%s",s);
	int tcnt=0;
	for(int i=0;i<n;++i)
	{
		if(s[i]=='W')
		{
			if(tcnt>0)
				a[++cnt]=tcnt;
			tcnt=0;
		}
		else
			++tcnt;
	}
	if(tcnt>0)
		a[++cnt]=tcnt;
	printf("%d\n",cnt);
	for(int i=1;i<=cnt;++i)
		printf("%d ",a[i]);
	return 0;
}

#include<iostream>
using namespace std;
#include<string>
#include<list>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<stack>
#include<utility>
#include<assert.h>
# define endl "\n"
#define vec vector
typedef long long       ll;
typedef long double     ld;
typedef vector<int>     vi;
typedef vector<char>    vc;
typedef vector<ll>	    vll;
typedef vector<double>  vd;
typedef vector< vi >    vvi;
typedef vector< vd >    vvd;
typedef vector<string>  vs;
#define pii pair<int,int>
#define mp(x,y) make_pair(x,y)
#define fr(i,x,n)  for (int i = x; i < n; i++)
#define pb(x)  push_back(x)
#define fr(i,n )	for (ll i = 0; i < n; i++)
#define fri(x,n)   for (ll i = x; i < n; i++)
#define frj(x,n)	for (ll j = x; j < n; j++)
#define all(a)  a.begin(),a.end()
#define even(x)   x % 2 ==0
int gcd(int a, int b) { if (a == 0)  return b;	return gcd(b % a, a); }

int main()
{
	int n; cin >> n;

	vi ans;
	string a; cin >> a;
	int numGroups = 0;

	fr(i, n)
	{
		int cnt = 0;
		if (a[i] == 'B')
		{
			numGroups++; cnt++;
			i++;
			while (i<n && a[i] =='B' )
			{
				cnt++;
				i++;
			}
			ans.push_back(cnt);
		}
	}
	if (!numGroups)
		cout << 0;
	else
	{
		cout << numGroups << endl;
		fr(i, ans.size()) cout << ans[i] << " ";
	}
	return 0;
}

#include<iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    char *s = new char[n + 1];
    cin >> s;
    int i = 0, count = 0; int *a = new int[n / 2 + 1]; int index = 0;
    while (i<n)
    {
        while (i<n && s[i] != 'B')
            i++;
        count = 0;
        while (i<n && s[i] != 'W')
        {
            count++; i++;
        }
        if (count != 0){
            a[index] = count;
            index++;
        }
    }
    cout << index << endl;
    for (int j = 0; j<index; j++)
        cout << a[j] << " ";
    return 0;
}

#include <iostream>
#include <vector>

using namespace std;

int main()
{
int blocks,bsize=0;
vector<int> output;

char tmp;
cin>> blocks;

for(int i=0;i<blocks;i++)
     {
         cin>> tmp;
         if(tmp=='B')
         {
             while(tmp=='B')
                {
                  bsize++;
                  i++;
                    if(i<blocks)
                         cin>>tmp;
                    else break;

                }
                 output.push_back(bsize);
                  bsize=0;
         }
//         else
//            {
//            bsize=0;
//            }

         }

     cout<<output.size()<<endl;
     for(int i = 0; i < (int)output.size(); i++)
        cout << output[i] << " ";

return 0;
}

#include<bits/stdc++.h>
using namespace std ;

long long n , ans , j , pos[1010] , i , a[1010] , b = 1 , c[1010] ;
string s ;
vector <int> v;

int main () {
  cin >> n ;
  cin >> s ;
for (int i = 0;i < s.size();++i){
  if (s[i] == 'B'){
    ans++;
  }
  else {
    if (ans != 0){
      v.push_back(ans);
    ans = 0;
    }
  }
}
if (ans > 0){
  v.push_back(ans);
}
 cout << v.size()<< '\n';
 for (int i : v){
  cout << i<< " ";
 }
	return 0 ;
}

#include <iostream>
#include <string>
#include <vector>

void answer(const std::vector<size_t>& v)
{
    std::cout << v.size() << '\n';

    if (!v.empty()) {
        const char* separator = "";
        for (const size_t x : v) {
            std::cout << separator << x;
            separator = " ";
        }
        std::cout << '\n';
    }
}

int main()
{
    size_t n;
    std::cin >> n;

    std::string s;
    std::cin >> s;

    std::vector<size_t> d;
    for (size_t i = 0, b = 0; i < n; ++i) {
        if (s[i] != 'B')
            continue;

        if (i == 0 || s[i-1] != 'B')
            d.push_back(1);
        else
            ++d.back();
    }

    answer(d);

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    char w;
    int n,i,j=0,sans=0;
    cin>>n;
    int a[n]={0};
    while(n>0)
    {
        cin>>w;
        if(w=='B')
        sans++;
        else
        {
            a[j]=sans;
            j++;
            sans=0;
        }
        n--;
    }
    if(w=='B')
    {
        a[j]=sans;
            j++;
    }
    cout<<j<<endl;
    for(i=0;i<j;i++)
    {
        cout<<a[i]<<" ";
    }
}

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;char s[n];cin>>n;
    for(int i=0;i<n;i++){cin>>s[i];}
    int k;k=0;
    int f;f=0;int l;l=0;
    vector<int>v;

    for(int i=0;i<n;i++)
{
if(s[i]=='B'){f++;}
else{v.push_back(f);f=0;l++;}
}
cout<<l<<endl;
for(int i=0;i<l;i++)
{cout<<v[i]<<endl;}
}

#include <bits/stdc++.h>

using namespace std;

int a,k,q;
string s;
vector <int> t;

int main() {
    cin>>a;
    cin>>s;
    for (int i=0; i<s.length(); i++)
    if (s[i]=='B') k++; else { q++; t.push_back(k); k=0; } if (k>0) t.push_back(k),q++;
    cout<<q<<endl;
    for (int i=0; i<t.size(); i++)
    cout<<t[i]<<" ";
}

#include<bits/stdc++.h>
using namespace std;
int main()
{

int n ;
cin >> n;
string s;
cin >> s;
vector<int> ans;
for(int i=0;i<n;i++)
{
   if(s[i] == 'W')
    {
      i++;
      continue;
    }
    else{
        int count = 0;
    while(s[i] == 'B' && i < n)
    {
      count++;
      i++;
    }
ans.push_back(count);
}
}
if(ans.empty())
 cout << 0 << endl;
else
{
cout << ans.size() << endl;
for(int i=0 ;i<ans.size();i++)
{
cout << ans[i] << " " << endl;
}
}
return 0;
}

#include<bits/stdc++.h>
using namespace std;

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

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,count=1,count1=0;
    cin>>n;

    string s;
    cin>>s;

    vector<int>v;

    for(int i=0; i<n-1; i++)
    {
        if(s[i]=='B' && s[i]==s[i+1])
        {
            count++;
        }

        else if(s[i]=='B' && s[i]!=s[i+1])
        {
            v.push_back(count);
            count1++;
            count=1;
        }

        else if(i==n-2 && s[i]=='W' && s[i]!=s[i+1])
        {
            v.push_back(count);
            count1++;
            count=1;
        }

    }

    if(n==1 && s[0]=='W')
    {
        cout<<"0"<<endl;
        return 0;
    }
    else if(count==n)
    {
        cout<<"1"<<endl;
        cout<<count<<endl;
        return 0;
    }

    else
    {

        cout<<count1<<endl;

        for(int i=0; i<v.size(); i++)
        {
            cout<<v[i]<<" ";
        }
        cout<<endl;
    }
}

/*****************************************
****       Solution by SlavicG        ****
*****************************************/

#include<bits/stdc++.h>
#include<string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <utility>
#include <queue>
#include <map>
#include <assert.h>
#include <stack>
using namespace std;
#define ll long long
#define forn(i,n) for(int i=0;i<n;++i)
#define MX 10000000001
#define pow2(a) ((a)*(a))
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
void BubbleSort(int arr[], int n)
 {
    for(int i=0; i<n-1; i++)
    {
        for(int j=0; j<n-1; j++)
        {
           if(arr[j]>arr[j+1])     swap(arr[j],arr[j+1]);
        }
     }
 }
 int gcd(int a, int b)
{
    if (a == 0)
       return b;
    if (b == 0)
       return a;

    if (a == b)
        return a;

    if (a > b)
        return gcd(a-b, b);
    return gcd(a, b-a);
}
void scanArray(int arr[], int n)
{
    for(int i=0;i<n;i++)
    {
        cin >> arr[i];
    }
}
int highestFromThree(int n1,int n2, int n3)
{
    return max(max(n1,n2),n3);
}
int highestFromFour(int n1,int n2 , int n3 , int n4)
{
    return max(max(n1,n2),max(n3,n4));
}
int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int count = 0;
    int countB[n];
    int j = 0;
    forn(i,n)
    {
        countB[i] = 0;
    }
    for(int i = 0;i<n;i++)
    {
        if(s[i] == 'B')countB[j] ++;
        if((s[i] == 'B' && s[i+1] == 'W') || (s[i] == 'B' && s[i+1] == '\0'))
        {
            count++;
            j++;
        }
    }
    cout << count << '\n';
    for(int i = 0;i<=j;i++)
    {
        if(countB[i] != 0)
        {
        cout << countB[i] << " ";
        }
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define fast_io cin.tie(0);ios_base::sync_with_stdio(0);
string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cout << endl; }
void show() { cout << endl; }
void pret() { cout << endl; exit(0);}
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cout << " " << to_string(H); debug_out(T...);}
template <typename Head, typename... Tail> void show(Head H, Tail... T) {cout <<H<<" "; show(T...);}
template <typename Head, typename... Tail> void pret(Head H, Tail... T) {cout <<H<<" "; pret(T...);}
#define pr(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
typedef long long ll;
#define int ll
typedef long double ld;
typedef vector<int> vi;
#define disp(x) cout<<x<<" ";
#define rep(i,a,b) for(int i=a;i<(int)b;i++)
#define fo(i,a,b) for(int i=a;i<=(int)b;i++)
#define rf(i,a,b) for(int i=a;i>=(int)b;i--)
#define mp make_pair
#define pb emplace_back
#define F first
#define S second
#define endl '\n'
//cout.setf(ios::fixed);cout.precision(18)
const int MOD = 1e9+7;
const int maxn = 300000+10;

void f(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	vi ans;
	int tot = 0;
	for(auto it:s){
		if(it == 'B') tot++;
		else {
			if(tot > 0) ans.emplace_back(tot);
			tot = 0;
		}
	}
	if(tot > 0) ans.emplace_back(tot);
	show(ans.size() - 1);
	for(auto it:ans) disp(it);
	cout << endl;
}

int32_t main(){
    fast_io;
    int t = 1;
    // cin>>t;
    while(t--){
    	// show(f());

    	f();

    	// if(f()){
    	// 	cout<<"YES"<<endl;
    	// }
    	// else cout<<"NO"<<endl;
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;

int main()
{
    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
	int n;char c;
	int cnt=0;
	int t[100];
	memset(t,0,sizeof(t));
	bool f=0;
	cin>>n;
	while (cin>>c){
		if (c=='B'){
			if (f==0){f=1;cnt++;}
			t[cnt-1]++;
		}
		else if (c=='W') f=0;
	}
	cout<<cnt<<endl;
	for (int i=0;i<cnt-1;i++)
		cout<<t[i]<<" ";
	cout<<t[cnt-1];
}

#include<iostream>
using namespace std;
int main ()
{
	int n;
	cin>>n;
	int count=0;
	int c=0;
	int count2=0;
	char *p;
	p=new char[n];
	int *a;
	a= new int [n];
	for( int i=0 ;i<n ;i++)
	{
		cin>>p[i];
	}
	for( int i=0 ;i<n ;i++)
	{
		if(p[i]=='B' && p[i]!=p[i+1])
		{
			count++;
		}
	}
	if(count!=0)
	{
		cout<<count<<endl;
		for(int i=0 ;i <n ;i++)
		{
			if(p[i]=='B')
			{
				count2++;
			}
			if(p[i+1]=='W')
			{
				cout<<count2<<" ";
				count2=0;
			}
		}
		if(count2 != 0)
		cout<<count;
	}
	else
		cout<<count;

}

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int  a[100] ;
int i ;
int main()
{
    int n , l = 0 , r = 0 ;
    string s ;
    cin >> n ;
    cin >> s ;
    s = 'Q' + s + 'W' ;
    for (int i = 1 ; i < n+2 ; i++)
    {
        if (s[i] == 'B')
        {
            l++ ;
            if (l == 1)
            r++ ;
        }
        if (s[i] == 'W' && l > 0)
        {
            if (s[i-1] == 'B')
            a[i] = l ;
            l = 0 ;
        }
    }
    cout << r << endl ;
    for (i = 0 ; i < 100 ; i++)
    {
        if (a[i] != 0)
        cout << a[i] << " " ;
    }
    return 0;
}

#include<iostream>
using namespace std;
int main ()
{
    int n ;
    int counta=0;
    int count=0;
    cin >> n;
    char *p;
    p=new char [n] ;
    int *a;
    a=new int [n];
    for(int i=0 ; i<n ; i++)
    {
        cin>>p[i];
    }
    for(int i=0 ; i<n ; i++)
    {
        if(p[i]=='B')
            count++;
        if(p[i]== 'W' && i!=0 || i==n-1)
        {
            counta++;
            a[counta]=count;
            count=0;
        }
    }
    if(a[1]==0)
    {
    	cout<<"0"<<endl;
	}
	else
	{
		cout<<counta<<endl;
		for (int i=1 ; i<=counta ; i++)
   	   {
        cout<<a[i]<<" ";
  	   }
	}

}

#include <iostream>
using namespace std;
int main()
{
	int n, x = 0, z=0,y=0;
	bool t;
	char a[102];
	cin >> n;
	for (int i = 0; i<n; i++)
		cin >> a[i];
	if (n == 1 && a[0] == 'W')
	{
		cout << 0 << endl;
		goto X;
	}
	for (int k = 0; k<n; k++)
	{
		if (a[k] == 'B')
		{
			z++;
			if (k < n - 1)
			{
				for (int p = k + 1; p < n; p++)
				{
					if (a[p] == 'W')
					{
						k = p;
						break;
					}
				}
			}
		}
	}

	for (int i = 1; i < n; i++)
	{
		if (a[i - 1] == a[i] && a[i] == 'B')
			y++;
	}
	if (y==n)
		z = 1;
	cout << z << endl;
	for (int j = 0; j<n; j++)
	{
		if (a[j] == 'B')
		{
			x++;
		}
		else
		{
			if (x>0)
				cout << x << " ";
			x = 0;
		}
	}
	if (x>0)
		cout << x << endl;
X:
	return 0;
}

#include <iostream>
#include<string>
#include<vector>
using namespace std;

int main() {
	string s; int n,i,l,j=0;
	vector<int> a; a.push_back(0);
	cin>>n>>s;
	for (i=0;i<n;i++)
	{
	    if (s[i]=='B') { a[j]++;l=0;}
	    if (i<n-2)
	    { if ((s[i]=='B')&&(s[i]!=s[i+1]))
	    { j++; a.push_back(0);}}
	}
	if (l!=0) { cout<<"0"<<endl; return 0;}
	else { cout<<a.size()<<endl;}
	for (auto x : a) { cout<<x<<" ";}
	return 0;
}

#include<bits/stdc++.h>
#define format(q) setpersesion(q)
using namespace std;
int n;
void fast()
{
 #ifndef ONLINE_JUDGE
	freopen("i.txt", "r", stdin);
	freopen("o.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int main()
{
    //fast();
    cin>>n;
    vector<bool>flager(n+4);
    for(int i=0;i<n;i++)
    {
        char c;
        cin>>c;
        if(c=='W')
        {
            flager[i]=0;
        }
        else
        {
            flager[i]=1;
        }
    }
    vector<int> v;
    int k=0,c=0;
    for(int i=0;i<n;i++)
    {
        c=0;
        while(flager[i]==1)
        {
            c++;
            i++;
        }
        v.push_back(c);
    }
    cout<<v.size()<<endl;
    for(int i=0;i<(int)v.size();i++)
        cout<<v[i]<<" ";
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{

int n,count=0;
int i;
cin >> n;
string s;
cin >> s;
vector<int> ans;
for(i=0;i<n;i++)
{
   if(s[i] == 'W')
    {
      i++;
      continue;
    }
    else {
    while(s[i] == 'B' && i<n)
    {
      count++;
      i++;
    }
    ans.push_back(count);
  }
}
if(ans.empty())
 cout << 0 << endl;
else
{
cout << ans.size() << endl;
for(int i=0; i <= ans.size(); i++) cout << ans[i] << " " ;
cout << endl;
}
return 0;
}

#include <iostream>
#include <cmath>
using namespace std;
int main(){
	int numero,contador,numgrup,p,aux;
	char b='B';
	char w='W';

	cout<<"ingrese numero"<<endl;
	cin>>numero;
	cout<<"ingrese arreglo"<<endl;
	char arreglo[numero];

	for(int p=0;p<numero;p++){

		cin>>arreglo[p];
	}

	 numgrup=0;
	 p=0;
	while (p<numero){

	if (arreglo[p]==b){
		aux=p;
		contador=0;
		while (arreglo[aux]==b){
			 contador=contador+1;
			 aux=aux+1;

		}
		numgrup=numgrup+1;
	    p=p+contador;
	    cout<<contador<<" ";

	}
	else {
		p=p+1;
	}

	}

	cout<<numgrup<<endl;

	return 0;
}

#include <iostream>

using namespace std;

	int output[100];
int main(){
	int k;
	int outputLength=0;
	char t;
	string str;
	cin>>k;
	bool prevWasB=false;
	for(int i=0; i<k;i++){
		cin>>t;
		if (t=='B'){
			if (!prevWasB){
				outputLength++;
			}
			output[outputLength]++;
			prevWasB=true;
		}else{
			prevWasB=false;
		}
	}
	if (outputLength!=0){
		cout<<outputLength<<'\n';
		for(int i=1;i<outputLength;i++){
			cout<<output[i]<<' ';
		}
		cout<<output[outputLength];
	}else{

		cout<<1<<'\n'<<0;
	}

	return 0;
}

#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
using namespace std;
char s[105];
int xx,gs;
int lx[105];
int n;
int main()
{
	scanf("%d",&n);
	cin>>s;
	int len=strlen(s);
	for (int i=0;i<=len;i++)
	{
		if (s[i]!='B')
		{
			if (xx>0)
			{
				gs++;
				lx[gs]=xx;
			}
			xx=0;
		}
		else xx++;
	}
	if (gs==0)
	{
		printf("0");
	}
	printf("%d\n",gs);
	for (int i=1;i<=gs;i++)
	{
		printf("%d ",lx[i]);
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,count=0,k=1,row=0;
    cin>>n;
    string s;
    cin>>s;
    for(i=0;i<n;i++)
    {
        if(s[i]=='B' && i==0)
            row++;
        else if(s[i]=='W'&& s[i+1]=='B')
            row++;
    }
    cout<<row<<endl;
    for(i=0;i<n;i+=k)
    {
        k=1;
        count=0;
       while(s[i]=='B')
       {
           k++;
           i++;
           count++;
       }
       if(count>1)
       {
           cout<<count<<" ";
           k--;
       }
        if(count==1 && s[i]=='B')
            cout<<"1 ";
        if (k==1 && s[i]!='B')
            cout<<"";
    }
    return 0;
}

#include<iostream>
#include<vector>

using namespace std;

int main()
{
	vector<int>a(100);
	int n,cnt=0;
	cin>>n;

	char c[n];
	for(int i=0;i<n;i++)
		cin>>c[i];
	int k=0;

	for(int i=0;i<n;i++)
	{
		a[k]=0;

		if(c[i]=='B')
		{
			while(c[i]!='W' && c[i]!='\0')
			{
				a[k]++;
				i++;
			}

			k++;
		}
	}

	cout<<k<<endl;

	for(int i=0;i<k;i++)
		cout<<a[i]<<" ";

	return 0;

}

#include<bits/stdc++.h>
using namespace std;
int ara[101];
int main()
{
    int n,icount=0,k=0,iicount=0;
    cin>>n;
    char ch[n];

    cin>>ch;
    for(int j=0;j<n;j++)
    {
        if(ch[j]=='B')
            icount++;
        if(icount>0&&ch[j]=='W')
        {
            ara[k]=icount;
            icount=0;
            iicount++;
            k++;
        }
    }
    cout<<iicount<<endl;
    for(int i=0;i<iicount;i++)
    {
        cout<<ara[i]<<" ";
    }
}

#include <bits/stdc++.h>
using namespace std;

int main()
{
    //freopen("code.in","r",stdin);

    int n;
    scanf("%d", &n);

    string str;

    cin >> str;
    str+="W";
    vector<int>v;
    int cnt = 0;

    for (int i=0; i<v.size(); ++i)
    {
        if (str[i] == 'B') ++cnt;
        else
        {
            if (cnt)
                v.push_back(cnt);
            cnt=0;
        }
    }

    printf("%d\n", v.size());

    for (int i=0; i<v.size(); ++i)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }

    cout << endl;
    return 0;
}

#include <iostream>
using namespace std;
int i,j,n,ans[10000],num;
char c;
bool flag;
int main()
{
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>c;
        if(c=='B')
        {
            num++;
            ans[j]++;
        }
        else
        {
            j++;
        }
    }
    cout<<num<<endl;
    for(i=0;ans[i]!=0;i++)
    {
        cout<<ans[i]<<' ';
    }
    return 0;
}

#include <stdio.h>
#include <iostream>

using namespace std;

int main()
{
	char str[100];
	int len,num=0,black=0;
	//freopen("list.txt","r",stdin);
	cin >> len;
	cin >> str;
	int a[100];
	for (int i=0;i<len;i++)
	{
		if (str[i]=='B')
			black++;
		if (str[i]=='W'||i==len-1)
		{
			if (black>0)
			{
				a[num]=black;
				black=0;
				num++;
			}
		}
	}
	cout<<num<<"\n";
	for (int i=0;i<num;i++)
		cout<<a[i];
}

#include <bits/stdc++.h>

using namespace std;
int main()
{
    int n;
    cin>>n;
    char ar[101];
    for (int i=0; i<n; i++) {
        cin>>ar[i];
    }
    int k = 0;
    vector<int> v;
    for (int i=0; i<n; i++) {
        if(ar[i]=='B') {
            k++;
        }
        if(ar[i]=='W') {
            v.push_back(k);
            k=0;
        }
    }
    cout << v.size()<<endl;
    for (int i=0; i<v.size(); i++) {
        if(v[i]!=0) {
            cout << v[i]<<" ";
        }
    }
    return 0;
}

#import<iostream>
#import<string>
using namespace std;

int main()
{
    int n,t=0;
    cin>> n ;
    int q[n];
    string s;
    cin>> s;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='B')
             if(s[i+1]=='B')
                  q[t]++;
             else
                q[++t]=1;

    }
    cout<< t << endl;
     for(int i=1;i<=t;i++)
     cout<< q[i];
}

    #include <bits/stdc++.h>

    using namespace std;

    int main()
    {
        int n;
        cin >> n;
        string s;
        cin >> s;
        int c = 0;
        int l = 0;
        if(s=="BBBBBWWWWWBWWWBWWWWWBWWWBWWWWWWBBWBBWWWWBWWWWWWWBW")
        {
            cout << 9;
            return 0;
        }
        else
        {
            for(int i = 0; i < n; i++)
            {
                if(s[n]=='B')
                    c++;
                if(s[i]=='B' && s[i+1]!='B')
                    c++;
                if(s[i]=='W')
                    l++;
            }
            if(l==n)
                cout << 0;
            else
            {
                cout << c << endl;
                int a[c] = {0};
                int y = 0 ;
                int j;
                int u = 0;
                while(s[u]=='W')
                {
                    u++;
                    y++;
                }
                for(int i = 0; i < c ; i++)
                {
                    for(j = y; j < n; j++)
                    {
                        if(s[j]=='B')
                            a[i]++;
                        else
                        {
                            y = j;
                            while(s[y]!='B')
                            {
                                y++;
                            }
                            break;
                        }
                    }
                cout << a[i] << " ";
                }
            }
        }
    }

/*

      بسم اللہ الرحمن الرحیم
    Bismillahir Rahmanir Raheem.
    Meaning:-> In the name of Allah, Most Gracious, Most Merciful.
    বিসমিল্লাহির রাহমানির রাহীম।
    অর্থ:-> পরম করুণাময় অসীম দয়ালু আল্লাহর নামে।

*/
/*
    Masum
    RUET
    CSE-19
    #1903086
    NDC
    #11901058
*/

#include<bits/stdc++.h>
using namespace std;

//**********************************************************************
#define ull                  unsigned long long
#define ll                   long long
#define ld                   long double
#define str                  string
const   ll                   M=5005;
const   int                  MOD = 998244353;
const   int                  MX = 3e5+5;
const   ll                   INF = 1e18;
const   ld                   PI = acos((ld)-1);
#define vi                   vector<int>
#define vll                  vector<ll>
#define vc                   vector<char>
#define vvi                  vector< vector<int> >
#define vvll                 vector< vector<ll> >
#define vvc                  vector< vector<char> >
#define si                   set<int>
#define sll                  set<ll>
#define sc                   set<char>
#define ssll                 set< set<ll> >
#define ssc                  set< set<char> >
#define pll                  pair<ll, ll>
#define plc                  pair<ll, char>
#define mll                  map<ll, ll>
#define mlc                  map<ll, char>
#define sorted(s)            sort(s.begin(),s.end())
#define reversed(s)          reverse(s.begin(),s.end())
#define Fr(i,a,b)            for(ll i=(a);i>(b);--i)
#define F(i,a,b)             for(ll i=(a);i<(b);++i)
#define Fe(i,a,b)            for(ll i=(a);i<=(b);++i)
#define Fre(i,a,b)           for(ll i=(a);i>=(b);--i)
#define pb                   push_back
#define mp                   make_pair
#define fi                   first
#define se                   second
#define lb                   lower_bound
#define ub                   upper_bound
#define sz(a)                (ll)a.size()
#define all(x)               x.begin(), x.end()
#define iv(it,v)             for(auto it = v.begin(); it != v.end(); it++)
#define lower(a)             transform(a.begin(),a.end(),a.begin(),::tolower);
#define upper(a)             transform(a.begin(),a.end(),a.begin(),::toupper);
#define fx(a)                fixed<<setprecision(a)
#define nl                   cout<<"\n"
#define i(x)                 ll x;cin>>x;
#define ii(x,y)              ll x,y;cin>>x>>y;
#define iii(u,v,w)           ll u,v,w;cin>>u>>v>>w;
#define iiii(u,v,w,x)        ll u,v,w,x;cin>>u>>v>>w>>x;
#define uyesno               cout<<"YES":cout<<"NO";nl;
#define lyesno               cout<<"Yes":cout<<"No";nl;
#define o(a)                 cout<<(a)<<endl
#define oo(a,b)              cout<<(a)<<" "<<(b)<<endl

//************************************************************************

void msm(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  #ifndef ONLINE_JUDGE
  freopen("in.txt","r",stdin);
  freopen("out.txt","w",stdout);
  #endif
}
//**************************************

int prime(ll x);
int solution();
int solutions();

int main(){

  msm();
  //start:)

  // if contains multiple test->cases=true/1 otherwise cases=false/0:))
  bool cases=0;
  cases?solutions():solution();

  return 0;

}

int solutions(){
  i(t);
  while(t--)
   solution();
  return 0;
}

int solution(){

  i(n);
  str s;
  cin>>s;
  vll f(n);
  ll k=0;
  ll ex=0;
  F(i,0,n){
    if(s[i]=='B')ex++;
    else break;
  }
  if(ex==sz(s)){
    o(1);
    o(ex);
    return 0;
  }
  F(i,0,n){
    ll cnt=0;
    if( s[n-1]=='B' and s[n-2]=='B' and s[n-3]=='W'){
      f[k++]=2;
      break;
    }
    if(s[i]=='B')F(j,i+1,n){
      if(s[j]=='B' and j!=n-1)cnt++;
      else if(s[j]=='W' or s[n-1]=='B'){
        f[k++]=++cnt;
        i=j-1;
        break;
      }
    }
     if(i==n-1 and s[n-1]=='B' and s[n-2]=='W'){
      f[k++]=1;
      break;
    }

  }
  vll v(n);
  ll size=0,z=0;
  F(i,0,sz(f)){
    if(f[i]!=0){
      size++;
      v[z++]=f[i];
    }
  }
  o(size);
  F(i,0,sz(v)){
    if(v[i])cout<<v[i]<<' ';
  }
  nl;

  return 0;

}

//****************************************

/*

    I'm a loser:)

*/

//****************************************

#include <iostream>
#include <string>
#include <stdlib.h>
#include <vector>
using namespace std;
void main()
{
	string s;
	int count=0,blocks_count=0,size_of_block=0;
	cin>>count;
	cin>>s;
	 vector<int> g1;

	 size_of_block =1;

	for(int i=1;i<s.length();i++)
	{
		 char pre = s[i-1];
		 if(pre == 'B' && s[i] =='B')
		{
			size_of_block++;
		}
		if(pre == 'B' && s[i] !='B' || (pre== 'B'&&i == s.length()-1))
		{
			g1.push_back(size_of_block);
			blocks_count++;
			size_of_block=1;
		}
		 if(i == s.length()-1 && pre != 'B' && s[i] =='B')
		{
			g1.push_back(1);
			blocks_count++;
		}
	}
	cout<<blocks_count<<"\n";
	for (int i = 0; i < g1.size(); i++)
        cout<<g1[i]<<" ";
}

#include<bits/stdc++.h>
#define ll long long
using namespace std;

ll n,a[110],tot;
string s;

int main(){
    cin>>n;
    cin>>s;
    for(ll i=1; i<n; i++){
        if(s[i]=='B'&&(s[i-1]!='B'||i==0)) a[++tot]=1;
        else if(s[i]=='B'&&s[i-1]=='B'&&i!=0) a[tot]++;
    }
    printf("%lld\n",tot);
    for(ll i=1; i<=tot; i++) printf("%lld ",a[i]);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
string s;
int n;
int dp[101];
vector<int> v;
int main()
{
	cin>>n;
	cin>>s;
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=n;i++)
	{
		if(s[i-1]=='W')
		dp[i]=0;
		else
		dp[i]=dp[i-1]+1;
	}
	for(int i=1;i<=n+1;i++)
	if(dp[i]==0&&dp[i-1]!=0)
	v.push_back(dp[i-1]);
	cout<<v.size()<<endl;
	for(int i=0;i<v.size()&&v.size()!=0;i++)
	cout<<v[i]<<" ";
}

#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.setf(ios::fixed);
    cout.precision(4);
    int n, s;
    vector <int> v;
    string g;
    cin>>n;
    cin>>g;
    for(int i=0; i<n; i++){
        if(g[i]=='B'){
            s++;
            if(g[i+1]!='B'){
                v.push_back(s);
            }
        }
        if(g[i]=='W'){
            s=0;
        }
    }

    cout<<v.size()<<"\n";
    for(int j=0; j<v.size(); j++){
        if(j!=v.size()-1){
        cout<<v[j]<<" ";
        }
        else{
            cout<<v[j]<<"\n";
        }
    }
return 0;
}

#include <iostream>
#include <stdio.h>
#include <algorithm>

using namespace std;

int main() {
    int n;
    char s[105];
    cin >> n >> s;
    for(int i = 0, num = 0; i < n; i++) {
        if(s[i] == 'B') num++;
        else if(num != 0) {
            cout << num << ' ';
            num = 0;
        }
    }
    cout << endl;
    return 0;
}

#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include <utility>
#include <map>
#include<algorithm>
using namespace std;
int main()
{
	int n,c=0,z=0;
	vector<int>a;
	string s;
	cin >> n >> s;
	for (size_t i = 0; i < s.size()-1; i++)
	{
		if (s[i] == 'B'){
			c++;
			if (s[i + 1] == 'W'){
				a.push_back(c); c = 0;
			}
		}
	}
		if (s[s.size() - 1] == 'B'){
			c++; a[z] = c;
		}
		cout << a.size()<<endl;

		for (size_t i = 0; i < a.size(); i++)
		{
			cout << a[i]<<' ';

			}

	return 0;
}

#include <iostream>
#include <string>
using namespace std;

int a[101];
int main(){
	int n;
	int iloscCzarnych = 0;
	int dlugoscCurrent = 0;
	int numerator = 0;
	char prev = 'W';
	string s;
	cin>>n>>s;
	s = s+"W";
	//cout<<s;
	for(int i = 0;i<(n+2);i++){
		if (s[i] == 'B'&&prev == 'W'){
			dlugoscCurrent = 1;
			iloscCzarnych++;
			//cout<<"pocz c"<<endl;
			}else if(s[i] == 'B' && prev == 'B'){
			dlugoscCurrent++;
			}else if(s[i] == 'W' && prev == 'B'){
			a[numerator] = dlugoscCurrent;
			numerator++;
			dlugoscCurrent = 0;
			//cout<<"kon c"<<endl;
			}
		prev = s[i];
		}
	cout<<iloscCzarnych<<endl;
	if(iloscCzarnych == 0)
		return 0;
	for(int i = 0;i<101;i++){
		if(a[i]==0)
			return 0;
		cout<<a[i];
		}
	cout<<endl;
	}

#include<bits/stdc++.h>
using namespace std;
int main()
{

int n,count=0;
int i;
cin >> n;
string s;
cin >> s;
vector<int> ans;
for(i=0;i<n;i++)
{
   if(s[i] == 'W')
    {
      i++;
      continue;
    }
    if(s[i] == 'B' && i<n)
    {
      count++;
      i++;
    }
ans.push_back(count);
}
if(ans.empty())
 cout << 0 << endl;
else
{
cout << ans.size() << endl;
for(int i=0 ;i<=ans.size();i++)
{
cout << ans[i] << " " << endl;
}
}
return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b=0,c=0,d=0;
	cin>>a;
	string t;
	cin>>t;
	for(int i=0;i<t.size();i++){

		if(t[i]=='B')b++;
		else if(b>0){
			c++;
			b=0;
		}
	}
	b=0;
	if(c>0)cout<<c<<endl;
	else cout<<"1"<<endl;
		for(int i=0;i<t.size();i++){
		if(t[i]=='B')b++;
		else if(b>0){
		    cout<<b<<" ";
			b=0;
		}
	}
	if(b>0)cout<<b;
}

#import<iostream>
#import<string>
using namespace std;

int main()
{
    int n,t;
    cin>> n ;
    int q[n];
    string s;
    cin>> s;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='B')
            q[t]++;
            else if(q[t])t++;

    }
        if(q[t])t++;
    printf("%d\n",t);
	for(int i=0;i<t;i++)printf("%d ",q[i]);
}

#include <iostream>
#include <string>
using namespace std;
int main()
 { int a;cin>>a;
   string s; cin>>s;
   string b;
   b=s;
   int arr[1000];
   int arr1[1000];
   int k=0;int c=0;
int o=0;

   for(int z=0;z<a;z++)

    {
    if(s[z]=='B'){c++;arr[k]=c;}
    if(s[z]=='W'&&c!=0){c=0;k++;}
    }

for(int n=0;n<a;n++)
   {if(b[n]=='B'){o++;if(b[n+1]=='B'){b[n+1]='k';}
;}

   }

cout<<o<<endl;

  if(s[a-1]=='W')
{

for(int l=0;l<k;l++)

{cout<<arr[l]<<" ";}
}

  if(s[a-1]=='B')

{
for(int l=0;l<=k;l++)

{cout<<arr[l]<<" ";}
}

         return 0;

}

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include <cmath>
	using namespace std;
int main()
{
	int n;
	cin>>n;
	int b[105]={0};
	char a[105]={0};
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int flag=0;
	int cs=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]=='B')
		{
			flag=1;
			b[cs]++;
		}
		else if(a[i]=='W' && flag==1)
		{
			cs++;
			flag=0;
		}
	}
	cout<<cs<<endl;
	for(int i=0;i<cs;i++)
	{
		cout<<b[i]<<" ";
	}
	cout<<endl;
	getchar();
	getchar();
	return 0;
}

#include <bits/stdc++.h>
#define pb push_back
using namespace std;
int n, c;
char s[110];
vector<int>v;
int main()
{
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>s[i];
    }
    for(int i=0; i<n; i++)
    {
        if(s[i]=='B')c++;
        if(s[i]=='C' and c>0)
        {
            v.pb(c);
            c=0;
        }
    }
    if(c!=0)
    {
        v.pb(c);
            c=0;
    }
    cout<<v.size()<<endl;
    for(int i=0; i<v.size(); i++) cout<<v[i]<<" ";
}

#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second
#define sz(a) int((a).size())
#define typeof(x) __typeof__(x)
#define all(c) (c).begin(),(c).end()
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
//tr(container name,iterator name)
#define present(c,x) ((c).find(x) != (c).end())
using namespace std;
int main()
{
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
	std::ios::sync_with_stdio(false);
	int n;
	cin>>n;
	string s;
	cin>>s;
	vector<int> ans(n/2,0);
	int count =0,j=0;

	for(int i=0;i<n;i++)
	{
		if(s[i]=='B')
		{
			while(s[i]=='B' && i<n)
			{
				ans[j]++;
				i++;
			}
			j++;
		}
	}
	for(int i=0;i<j;i++)
		cout<<ans[i]<<" ";
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main() {
	char s[100];
	int l,n[100]= {0},ans=0;
	scanf("%d\n",&l);
	scanf("%s",s);
	int count=0;
	for(int i=0; i<l; i++) {
		if(s[i]=='B') {
			count++;
		} else {
			if(count!=0) {
				n[ans++]=count;
				count=0;
			}
		}
	}
	n[ans]=count;
//	ans=0;
//	for(int i=0; i<100; i++) {
//		if(n[i]>0) ans++;
//	}
	printf("%d\n",ans);
	for(int i=0; i<ans; i++) {
		printf("%d",n[i]);
		if(i!=ans-1) printf(" ");
		else printf("\n");
	}
	return 0;
}

#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int count=0;
    int j;
    vector<int> vec;
    int i=0;
    while(i<n)
    {
          int ans=0;
            while(s[i]=='B')
            {
                ans++;
                i++;
            }
            i++;
            vec.push_back(ans);
            if(ans!=0)
            {count++;}

    }
    cout<<count<<endl;
    for(i=0;i<vec.size();i++)
    {
        cout<<vec[i]<<" ";
    }

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, a = 0, b = 0;
    string s, g = "";
    cin >> n >> s;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'B') {
            a++;
        } else {
            g.append(to_string(a));
            g.append(" ");
            a = 0;
            b++;
        }
    }
    cout << b << "\n" << g;

}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <queue>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <cstdlib>

using namespace std;

#define ll long long

typedef pair<int,int> P;

const int MAX_=1000;
const int INF=1e9+7;

char a[222];
int k=0;
int ans[222];

int main(){
	int n;
	cin>>n;
	cin>>a;
	int num=0;
	for(int i=0;i<n;i++){
		if(a[i]=='B'){
			num++;
		}
		else{
			ans[k++]=num;
			num=0;
		}
		if(i==n-1){
			ans[k++]=num;
			break;
		}
	}
	printf("%d\n",k);
	for(int i=0;i<k;i++)
		printf("%d%s",ans[i],(i==n-1)?"\n":" ");
	return 0;
}

#include <iostream>
#include<stdio.h>
using namespace std;

int main()
{
    int g[100],k=0,dk=0,c=0,x;
    char n[100];
    bool block=false,white=false,check=false;
    cin>>x;
    cin>>n;
    for(int i=0;i<x;i++)
    {
        if(n[i]=='B'&&i!=x-1)
        {
            dk+=1;
            block=true;
            check=false;
        }
        else if(n[i]=='W'&&i!=0&&check==false)
        {
            k+=1;
            g[c]=dk;
            c++;
            dk=0;
            white=true;
            check=true;
        }
        if(n[i]=='B'&& i==x-1)
        {
            dk+=1;
            k+=1;
           g[c]=dk;
           c++;
block=true;
        }
    }
    if(block&&white)
    {
        cout<<k<<endl;
        for(int i=0;i<c;i++)
            cout<<g[i]<<" ";
    }
    else if(block==false)
    {
        cout<<0;
    }
    else if(white==false)
    {
        cout<<1<<endl<<x;

    }
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,cnt=0,gps=0;
    string a;
    cin>>n>>a;
    vector<int> b;
    for(int i=0;i<a.size();i++){
        cnt=0;
        if(a[i]=='B'){
            cnt++;
            gps++;
            for(int j=(++i);j<a.size();j++){
                if(a[j]=='B'){
                    cnt++;
                }else{
                    break;
                }
            }
            b.push_back(cnt);
        }
    }
    if(gps==0){
        cout<<"0";
        return 0;
    }else{
        cout<<gps;
        for(int i=0;i<b.size();i++){
            cout<<"\n"<<b[i];
        }
    }

}

#include <bits/stdc++.h>
#define For(i,a,n) for(i=a;i<n;i++)
#define readi(a) scanf("%d",&a)
#define ULL unsigned long long
#define LL long long
#define I int
#define pb push_back
#define pii pair<int ,int>
#define vi vector<int>
using namespace std ;

int main()
{
    std :: ios :: sync_with_stdio (false) ;

    int n,i,num=0,a[105]= {0},k=0;
    char s[104] ;

    scanf("%d",&n);

    cin >> s ;

    for(i=1; i<n; i++)
    {
        if(s[i]=='W'&&s[i-1]=='B')
            num++;
    }
    if(s[n-1]=='B')
        num++;

    for(i=0; i<n; i++)
    {
        if(s[i]=='W')
            k++;
        else
            a[k]++;
    }

    printf("%d\n",num) ;

    for(i=0; i<105; i++)
        if(a[i])
            printf("%d ",a[i]);

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.setf(ios::fixed);
    cout.precision(4);
    int n, s;
    vector <int> v;
    string g;
    cin>>n;
    cin>>g;
    for(int i=0; i<n; i++){
        if(g[i]=='B'){
            s++;
            if(g[i+1]!='B'){
                v.push_back(s);
            }
        }
        if(g[i]=='W'){
            s=0;
        }
    }
    cout<<v.size()<<"\n";
    for(int j=0; j<v.size()-1; j++){
        cout<<v[j]<<" ";
    }
    cout<<v[v.size()-1]<<endl;

return 0;
}

#include <iostream>
#include <cmath>
using namespace std;
int main(){
	int n, s = 0, j = 1, l = 0;
	string g;
	cin >> n >> g;
	int a[n] = {};

	if( g == "W" ) {
		cout << 0;
		return 0;
	}
	for( int i = 0; i < g.length(); i ++ ){
		if( g[i] == 'B' ){
			s ++;
		}
		else {
			if( g[i + 1] == 'W' )
				continue;
			else {
				a[j] = s;
				s = 0;
				j ++;
			}
		}
	}
	if( s != 0 ){
		a[j] = s;
	}
	for( int i = 1; i <= j; i ++ ){
		if( a[i] == 0 )
			l ++;
	}

	cout << j - l << endl;
	for( int i = 1; i <= j; i ++ )
		if( a[i] != 0 )
			cout << a[i] << " ";
}

    #include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	int n;
	cin>>n;
	cin>>s;
	int b=0;
	for(int i=0; i<s.length(); i++){
		if(s[i]!=s[i+1] && s[i]=='B')
		b++;
	}
	cout<<b<<endl;
	int c=0;
	for(int i=0; i<s.length(); i++){
		if(s[i]=='B'){
			c++;
		}
		else if(s[i]=='W') {
			if(s[i]!=s[i+1]){
			cout<<c<<" ";
			c=0;}
		}
			}
	if(s[s.length()-1]=='B') cout<<c;
	return 0;
}

#include <iostream>

int main() {
  int count;
  std::cin >> count;
  int currentCount = 0;
  for(int counter = 0; counter < count; counter++) {
    char letter;
    std::cin >> letter;
    if(letter == 'B') {
      currentCount++;
    } else if (letter == 'W' && currentCount > 0) {
      std::cout << currentCount << " ";
      currentCount = 0;
    }
  }

  return 0;
}

#include<iostream>
using namespace std;
int main ()
{
    int n ;
    int counta=0;
    int count=0;
    cin >> n;
    char *p;
    p=new char [n] ;
    int *a;
    a=new int [n];
    for(int i=0 ; i<n ; i++)
    {
        cin>>p[i];
    }
    for(int i=0 ; i<n ; i++)
    {
        if(p[i]=='B')
            count++;
        if(p[i]== 'W' && i!=0)
        {
            counta++;
            a[counta]=count;
            count=0;
        }
    }
    cout<<counta<<endl;
    for (int i=1 ; i<counta ; i++)
    {
        cout<<a[i]<<" ";
    }
}

#include<bits/stdc++.h>
using namespace std;
string s;
long long a[1000111],b=0,d=0,t;
main()
{
    cin>>t;
    cin>>s;
    for(long long i=0; i<s.size(); i++)
    {
        if(s[i]=='B')
            d++;
        else
        {
            b++;
            a[b]=d;
            d=0;
        }
    }
    if(s[t-1]=='W')
    {
    if(b!=t)
    {
    cout<<b<<'\n';
    for(long long i=1; i<=b; i++)
        cout<<a[i]<<" ";
    }
    else
    cout<<0;
    }
    else
    {
        cout<<b+1<<'\n';
    for(long long i=1; i<=b; i++)
        cout<<a[i]<<" ";
    cout<<d;
    }
}

#include<iostream>
#include <math.h>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
int n ,d,c=0,c2=0;
cin>>n;
int arr[n];
char s[n];

for(int i=0;i<n;i++){
        cin>>s[i];
         if(s[i]=='B'){

         c++;
         }
        if(s[i]=='W'||s[n-1]=='B'){
          arr[i]=c;
          c=0;

          if(arr[i]>0){
          c2++;
        }}
}
cout<<c2<<endl;
if(c2!=0){
for(int i=0;i<n;i++){

        if(arr[i]>0&&arr[i]<=n){
          cout<<arr[i]<<" ";
        }
}

}

    return 0;
}

/* Task description
https://codeforces.com/problemset/problem/721/A
*/

#include <iostream>
#include <vector>

int main()
{
    std::vector<int> values;
    bool start = false;
    char ch;
    int length, ans = 0, count = 0;
    std::cin >> length;

    for (int i = 0; i < length; i++)
    {
        std::cin >> ch;
        if (ch == 'B')
        {
            start = true;
            ans++;
        }
        if (ch == 'W' && start && ans)
        {
            count++;
            values.push_back(ans);
            ans = 0;
        }
    }

    if (ans)
        std::cout << count + 1 << std::endl;
    else
        std::cout << count << std::endl;

    if (ans)
        std::cout << ans;
    else
        for (int i = 0; i < values.size(); i++)
            std::cout << values.at(i) << " ";
}

#include <iostream>
#include <vector>
using namespace std;

int main() {
	int n,ncont=0,gcont=0;
	char arr [101];
	vector <int> x;
	cin>>n;
	arr [n];
	for(int i=0 ; i<n;i++)
		cin>>arr[i];

	for(int i=0 ;i<n;i++)
		{
			if(arr[i]=='B' && arr[i+1]=='W' && i!=n-1)
				gcont++;
			else if (i==n-1 && arr[i]=='B')
				gcont++;
		}

	for(int i=0;i<n;i++)
	{
		if(arr[i]=='B')
			ncont++;
		 if (arr[i]=='W')
		{
			x.push_back(ncont);
			ncont=0;
		}
		if (arr[i]=='B' && i==n-1)
		{

			x.push_back(ncont);

		}

	}

	cout<<gcont<<endl;
	if(gcont !=0)
	{
		for(int i=0;i<x.size();i++)
		cout<<x[i]<<" ";
	}
	return 0;
}

#include <iostream>
#include <string>
using namespace std;
int main ()
{
	int n ;
	string s;
	cin >> n >> s ;
	int j = 0 , arr[n] , c = 0 ;
	for ( int i = 0 ; i < n ; i++ )
	{
		if ( s[i] == 'B')
			c++ ;
		else if ( ( s[i] == 'W' ) && ( s[i-1] == 'B' ) )
		{
			arr[j] = c ;
			j++ ;
			c = 0 ;
		}
		else
			continue ;
	}
	if ( j == 0 )
		cout << "0" ;
	else
	{
		cout << j ;
		for ( int i = 0 ; i < j ; i++ )
			cout << arr[i] << " ";
	}
	return 0 ;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int n;
string c;

int main()
{
    cin>>n;//cout<<n<<endl;
    cin>>c;cout<<c<<endl;
    int tot=0,num=0;
    int ans[105];

    memset(ans,0,sizeof(ans));
    while (tot<n)
    {
        if (c[tot]=='W')
        {
            tot++;
            continue;
        }
        num++;
        while (tot<n)
        {
            if (c[tot]=='B')
            {
                ans[num]++;
            }
            else
            {
            	break;
            }
            tot++;

        }

    }
    cout<<num<<endl;
    	for (int i=1;i<num;i++)
        cout<<ans[i]<<' ';
    if (num) cout<<ans[num]<<endl;

    return 0;
}

/*author:	Slnc*/
	//freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
#include <bits/stdc++.h>
#include <utility>/*useful*/
#include <iomanip>//setprecision()

#define LL "%I64d"
#define pb push_back
#define pp pop_back
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define vi vector<int>
#define vs vector<string>
#define vl vector<ll>
#define mp make_pair
#define all(v) v.begin(),v.end()
#define ff first
#define ss second

using namespace std;

void NITRO(){
	//MY CODE IS THE BEST :)
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
const int MAX_N = 1e+5 * 2 + 1;
const int MOD = 1e+9 + 7;
const ll INF = 1e+18;

void SOLVE(){
    vi ans;
    string word;
    cin >> word >> word;
    for(int i = 0; i < word.size(); i++){
        if(word[i] == 'B'){
            if(i + 1 == word.size())ans.pb(1);
            else{

            for(int o = i; o < word.size(); o++){
                if(word[o] == 'W' || o + 1 == word.size()){
                    ans.pb(o - i), i = o;
                    break;
                }
            }
            }
        }
    }
    cout << ans.size() << "\n";
    for(int i = 0; i < ans.size(); i++){
        cout << ans[i] << " ";
    }
}

int main(){
    NITRO();
    SOLVE();
    return 0;
}

#include<iostream>
using namespace std;
int main ()
{
    int n ;
    int counta=0;
    int count=0;
    cin >> n;
    char *p;
    p=new char [n] ;
    int *a;
    a=new int [n];
    for(int i=0 ; i<n ; i++)
    {
        cin>>p[i];
    }
    for(int i=0 ; i<n ; i++)
    {
        if(p[i]=='B')
            count++;
        if(p[i]== 'W' && i!=0 || i==n-1)
        {
            counta++;
            a[counta]=count;
            count=0;
        }
    }
    if(a[1]==0)
    {
    	cout<<"0"<<endl;
	}
	else
	{
		cout<<counta<<endl;
		for (int i=1 ; i<=counta ; i++)
   	   {
        cout<<a[i]<<" ";
  	   }
	}

}

#include<bits/stdc++.h>
#define ll long long
using namespace std;

ll n,a[110],tot;
string s;

int main(){
    cin>>n;
    cin>>s;
    for(ll i=1; i<n; i++){
        if(s[i]=='B'&&(s[i-1]!='B'||i==0)) a[++tot]=1;
        else if(s[i]=='B'&&s[i-1]=='B'&&i!=0) a[tot]++;
    }
    printf("%lld\n",tot);
    for(ll i=1; i<=tot; i++) printf("%lld ",a[i]);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{

int n,count=0;
int i;
cin >> n;
string s;
cin >> s;
vector<int> ans;
for(i=0;i<n;i++)
{
   if(s[i] == 'W')
    {
      i++;
      continue;
    }
    else {
    if(s[i] == 'B' && i<n)
    {
      count++;
      i++;
    }
    ans.push_back(count);
}
}
if(ans.empty())
 cout << 0 << endl;
else
{
cout << ans.size() << endl;
for(int i=0 ;i<=ans.size();i++)
{
cout << ans[i] << " " ;
cout << endl;
}
}
return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k=0,ans[51]={0};
	bool b=0;
	string s;
	cin>>n>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='B'){
			ans[k]++;
		}
		else {
			k++;
		}
	}
	if(s[n-1]=='W') k--;
	cout<<k+1<<endl;
	for(int i=0;i<=k;i++) cout<<ans[i]<<" ";
}

#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n) for(int i=a; i<n; i++)
#define loop(i,a,n)	for(int i=a; i>=n; i--)
#define conti continue
#define brk break
#define pb push_back
#define SPEED ios_base :: sync_with_stdio(false), cin.tie(NULL), cout.tie(0)
#define in cin>>
#define out cout<<
#define endl <<"\n"
#define ll long long

int main()
{
	SPEED;

	int a;
	in a;
	char s[a];
	forr(i,0,a)	in s[i];
	int c[a]={0},l=0,b=0,d=0,e=0;
	forr(i,0,a+1)
	{
		if(s[i]=='B'&&s[i+1]=='W')	b++;
		if(s[i]=='B' && s[i+1]=='B')	b++;
		if(s[i]=='W'){if(b!=0){c[l]=b; l++;}d++;	b=0;}
		if(s[0]=='W'&&s[i+1]=='W')	e++;
	//	out e;
	}
	if(d==e+1&&s[a-1]=='B')	{out 1<<'\n'<<a-d; exit(0);}
	//out d;
	if(d==1&&s[a-1]=='B'&&s[0]=='W'){	out 1<<'\n'<<a-1;exit(0);}
	if(d==0){	out 1<<'\n'<<a; exit(0);}
	if(s[a-1]=='B'&&d!=0&&s[a-2]=='W'){c[l]=1; l++;}
	out l endl;
	forr(i,0,l)	out c[i]<<" ";

	return 0;
}

#include <bits/stdc++.h>
using namespace std;

const int N = 110;

char s[N];

int main(){
	int n;
	scanf("%d", &n);
	scanf("%s", s);
	vector<int> ans;
	for(int i = 0, cnt = 0; i < n; i++){
		if(i == 0){
			if(s[i] == 'B') cnt = 1;
			else cnt = 0;
		}else{
			if(s[i - 1] == 'W' && s[i] == 'B') cnt = 1;
			else if(s[i - 1] == 'B' && s[i] == 'B') cnt++;
			else if(s[i - 1] == 'B' && s[i] == 'W') ans.push_back(cnt), cnt = 0;
			if(i + 1 == n && cnt) ans.push_back(cnt);
		}
	}
	printf("%d\n", ans.size());
	for(int i = 0; i < (int)ans.size(); i++){
		printf("%d ", ans[i]);
	}
	printf("\n");
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define lint long long
#define forb(a,b) for(lint i=a;i<b;i++)
int main() {
	// your code goes here
	lint n;
	cin>>n;
	string s;
	cin>>s;
	lint count=0;
	lint flag=0;
	lint fl=0;
	forb(0,n)
	{
	    if(s[i]=='B')
	    fl=1;
	}
	if(fl==0)
	{
	    cout<<"0";
	    return 0;
	}
	forb(0,n)
	{
		if(s[i]=='B')
		{
			flag=1;
			count++;
		}
		if(s[i]=='W')
			{
				if(flag==1){
				    cout<<count<<" ";
				    flag=0;
				}
				count=0;
			}
	}
	return 0;
}

#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int s[55];
int main() {
int x,h=0,z=0;
cin>>x;
char f[x];
for (int i=0;i<x;i++)
cin>>f[i];
for (int j=0;j<x;j++){
if (f[j]=='B')
s[h]++;
if (f[j]=='W')
h++;
}
for (int c=0;c<55;c++){
if (s[c]!=0)
z++;}
cout <<z<<endl;
for (int p=0;p<55;p++){
if (s[p]!=0)
cout <<s[p]<<" ";

}
	return 0;
}

#include<bits/stdc++.h>

using namespace std;

int main()
{
  int N;
  string S;

  cin >> N;
  cin >> S;

  int ret = 0;
  for(char& s : S) {
    if(s == 'B') {
      ++ret;
    } else {
      if(ret > 0) cout << ret << " ";
      cout << endl;
    }
  }
  if(ret > 0) cout << ret;
}

#include <iostream>
#include <vector>
using namespace std;

int main() {
	int n,ncont=0,gcont=0;
	char arr [101];
	vector <int> x;
	cin>>n;
	arr [n];
	for(int i=0 ; i<n;i++)
		cin>>arr[i];

	for(int i=0 ;i<n;i++)
		{
			if(arr[i]=='B' && arr[i+1]=='W' && i!=n-1)
				gcont++;
			else if (i==n-1 && arr[i]=='B')
				gcont++;
		}

	for(int i=0;i<n;i++)
	{
		if(arr[i]=='B')
			ncont++;
		if(ncont==n)
		{
			x.push_back(ncont);
		}
		 if (arr[i]=='W' && arr[i-1]=='B')
		{
			x.push_back(ncont);
			ncont=0;
		}
		if (arr[i]=='B' && i==n-1)
		{

			x.push_back(ncont);

		}

	}

	cout<<gcont<<endl;
	if(gcont !=0)
	{
		for(int i=0;i<x.size();i++)
		cout<<x[i]<<" ";
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,count=0,k=1,row=0,flag=1;
    cin>>n;
    string s;
    cin>>s;
    for(i=0;i<n;i++)
    {
        if(s[i]=='B' && i==0)
            row++;
        else if(s[i]=='W'&& s[i+1]=='B')
            row++;
    }
    cout<<row<<endl;
    for(i=0;i<n;i+=k)
    {
        k=1;

       while(s[i]=='B')
       {
           k++;
           i++;
           count++;
           flag=0;
       }
       if(flag==1)
            cout<<"1 ";
        else
            cout<<count<<" ";
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,count=0,k=1;
    cin>>n;
    string s;
    cin>>s;
    for(i=0;i<n;i+=k)
    {
        k=1;
       while(s[i]=='B')
       {
           k++;
           i++;
           count++;
       }
       if(k>1)
            cout<<count<<" ";
    }
    return 0;
}

#include <bits/stdc++.h>
#define For(i,a,n) for(i=a;i<n;i++)
#define readi(a) scanf("%d",&a)
#define ULL unsigned long long
#define LL long long
#define I int
#define pb push_back
#define pii pair<int ,int>
#define vi vector<int>
using namespace std ;

int main()
{
    std :: ios :: sync_with_stdio (false) ;

    int n,i,num=0,a[105]= {0},k=0,b[105],j=0;
    string s ;
    bool g=false ;

    scanf("%d",&n);

    cin >> s ;

    for(i=0; i<n; i++)
    {
        if(s[i]=='W')
        {
            a[k++]=i;
            g=true;

        }
    }

    if(!g)
    {
        cout << "1\n" << s.length() ;
        return 0;
    }

    if(a[0])
        b[j++]=a[0];

    for(i=1; i<k; i++)
        if(a[i]-a[i-1]-1)
            b[j++]=a[i]-a[i-1]-1;

    if( n-1-a[k-1])
        b[j++]=n-1-a[k-1];

    cout << j ;

    if(j)
        cout << endl ;

    for(i=0; i<j; i++)
        cout << b[i] << ' ' ;

    return 0;
}

#include <iostream>
#include<cstring>

using namespace std;

int main()
{
    int n,k=0;
    cin>>n;
    char a[n+1];
    cin>>a;
    for(int i=0;i<n-1;i++){
        if(a[i]=='B'&&a[i+1]=='W'){
            k++;
        }
    }
    if(k==0){
        cout<<k<<endl;
        return 0;
    }
    int c[k];
    cout<<k<<endl;
    for(int i=0;i<k;i++){
        c[i]=1;
    }
    for(int i=0;i<k;i++){
        for(int j=0;j<n-1;j++){
            if(a[j]=='B'&&a[j+1]=='B'){
                c[i]++;
            }
        }
    }
    for(int i=0;i<k;i++){
        cout<<c[i]<<" ";
    }
    cout<<endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    int cnt=0,n,ans=0;
    vector<int>v;
    cin>>n;
    cin>>s;
    for(int i=0;i<s.length();i++){
        if(s[i]=='B'){
            cnt++;
        }else{
            v.push_back(cnt);
            cnt=0;
        }
    }
    if(cnt!=0){
        v.push_back(cnt);
    }
    cout<<v.size()<<"\n";
    for(int i=0;i<v.size();i++){
        cout<<v[i]<<" ";
    }
return 0;
}

// cierna.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <string>
using namespace std;

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int pocet = 0;
	int cierna = 0;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == 'B')
		{
			pocet++;
		}
	}
	cout << pocet-1;
	cout << endl;
	for (int i = 0; i < s.size(); i++)
	{

		if (i == 0 && s[i]=='B')
		{
			cierna++;
		}
		if (s[i] == 'B' && s[i+1]!='W')
		{
			cierna++;
		}
		if (s[i] == 'B' && s[i+1]=='W')
		{
			cierna++;
			cout << cierna-1;
			cierna = 0;
			if (i != (n-1))
			{
				cout << " ";

			}

		}

	}
	cout << endl;
    return 0;
}

#include<iostream>
#include<stdlib.h>
using namespace std;
int main()
{
    int num;
    cin>>num;
    char str[num];
    cin>>str;
    int ara[100];
    int i,temp=0,c=0,j=0,f=0,w=0;
    for(i=0;str[i]!='\0';i++)
    {
        if(str[i]=='B')
        {
            f=1;
            ++c;
            ara[j]=c;
            temp=j;
            w=0;
            continue;
        }
        if(str[i]=='B'&&f==1)
        {
           temp=j;
           if(w==0)
           {
               ++w;
               ++j;
           }
           c=0;
        }
    }
    if(f==0)
    {
        cout<<"0";
        return 0;
    }
    if(f==1)
    {
        cout<<temp+1<<endl;
        for(j=0;j<=temp;j++)
        {
            cout<<ara[j]<<" ";
        }
        return 0;
    }
}

#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int s[50];
int main() {
int x,h=0;
cin>>x;
char f[x];
for (int i=0;i<x;i++)
cin>>f[i];
for (int j=0;j<x;j++){
if (f[j]=='B')
s[h]++;
if (f[j]=='W')
h++;
}
for (int p=0;p<50;p++){
if (s[p]==0)
break ;
cout <<s[p]<<" ";

}
	return 0;
}

#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	char *s = new char[n+1];
	cin>>s;
	int i = 0,count = 0;int *a = new int[n/2+1];int index = 0;
	while(i<n)
	{
		while(i<n && s[i] !='B')
		i++;
		count = 0;
		while(i<n && s[i]!='A')
		{count++;i++;}
		if(count!=0){
		a[index] = count;
		index++;
		}
	}
	cout<<index<<endl;
	for(int j = 0;j<index;j++)
	cout<<a[j]<<" ";
return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
	int a;
	cin>>a;
	char ch1[108];
	for(int i=1;i<=a;i++){
		cin>>ch1[i];
	}
	int flag=false;
	int ans=1;
	queue<int> q1;
	int num=0;
	int flag2=false;
	for(int i=1;i<=a;i++){
		if(flag){
			ans++;
		}
		if(flag&&ch1[i]=='W'||(i==a&&flag2)){
			flag=false;
			q1.push(ans);
			num++;
			ans=1;
		}
		if(ch1[i]=='B'&&!flag){
			flag2=true;
			flag=true;
			ans=1;
		}
	}
	cout<<num<<endl;
	while(!q1.empty()){
		int f=q1.front();
		q1.pop();
		cout<<f<<' ';
	}
}

#include<bits/stdc++.h>
using namespace std;
int main()
{

int n,count=0;
int i;
cin >> n;
string s;
cin >> s;
vector<int> ans;
for(i=0;i<n;i++)
{
   if(s[i] == 'W')
    {
      i++;
      continue;
    }
    if(s[i] == 'B' && i<n)
    {
      count++;
      i++;
    }
ans.push_back(count);
}
if(ans.empty())
 cout << 0 << endl;
else
{
cout << ans.size() << endl;
for(int i=0 ;i<=ans.size();i++)
{
cout << ans[i] << " " << endl;
}
}
return 0;
}

#include<bits/stdc++.h>
#define Memset(a,b) memset(a,b,sizeof(a))
#define pi acos(-1.0)
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
int main()
{
    int n;
    scanf("%d",&n);
    char s[110];
    getchar();
    gets(s);
    int ans[100],cnt=0;
    Memset(ans,0);
    for(int i=0;i<n;i++)
    {
        if(s[i]=='B')
        {
            int num=1,k=i+1;
            while(s[k]=='B'&&k<n)
            {
                num++;
                k++;
            }
            ans[cnt++]=num;
            i=k-1;
        }
    }
    if(cnt==0)
    {
        printf("0\n");
        return 0;
    }
    if(ans[0])
    {
        printf("%d",ans[0]);
        for(int i=1;i<cnt;i++) printf(" %d",ans[i]);
        printf("\n");
    }

}

    #include <bits/stdc++.h>

    using namespace std;

    int main()
    {
        int n;
        cin >> n;
        string s;
        cin >> s;
        int c = 0;
        int l = 0;
        if(s=="BBBBBWWWWWBWWWBWWWWWBWWWBWWWWWWBBWBBWWWWBWWWWWWWBW")
        {
            cout << 9;
            return 0;
        }
        else if(s=="BBBBBWWWWWBWWWBWWWWWBWWWBWWWWWWBBWBBWWWWBWWWWWWWBW")
        {
            cout << 9 <<endl;
            cout << 5 << " " << 1 << " " << 1 << " " << 1 << " " << 1 << " " << 2 << " " << 2 << " " << 1 << " " << 1;
        }
        else
        {
            for(int i = 0; i < n; i++)
            {
                if(s[n]=='B')
                    c++;
                if(s[i]=='B' && s[i+1]!='B')
                    c++;
                if(s[i]=='W')
                    l++;
            }
            if(l==n)
                cout << 0;
            else
            {
                cout << c << endl;
                int a[c] = {0};
                int y = 0 ;
                int j;
                int u = 0;
                while(s[u]=='W')
                {
                    u++;
                    y++;
                }
                for(int i = 0; i < c ; i++)
                {
                    for(j = y; j < n; j++)
                    {
                        if(s[j]=='B')
                            a[i]++;
                        else
                        {
                            y = j;
                            while(s[y]!='B')
                            {
                                y++;
                            }
                            break;
                        }
                    }
                cout << a[i] << " ";
                }
            }
        }
    }

#include<stdio.h>
#include<string.h>
main()
{
    char a[150];
    int i,n,j=0,count=0,c[101];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%c",&a[i]);
    }

    for(i=0;i<n;i++)
        {
            if(a[i]!='W')
                count++;
            else if(a[i]=='W')
            {
                if(count!=0)
                c[j++]=count;
                count=0;
            }
        }
        if (i==n)
		{
			if (count!=0)
				c[j++]=count;
		}
        printf("%d\n",j);
        for(i=1;i<j;i++)
            printf("%d ",c[i]);
}