#include<bits/stdc++.h>
using namespace std;
string s,tmp1,tmp2;
int len,cnt,pos,ans;
void help(int x)
{
cnt=pos=0;
tmp1=s.substr(x)+s.substr(0,x);
for(int i=len-1; i>=0; i--)
tmp2[len-1-i]=tmp1[i];
while(tmp1[pos]=='w')
{
cnt++;
pos++;
}
for(int i=pos; i<len; i++)
if (tmp1[pos]==tmp1[i]||tmp1[i]=='w')
cnt++;
else
break;
pos=0;
while(tmp2[pos]=='w')
{
cnt++;
pos++;
}
for(int i=pos; i<len; i++)
if (tmp2[pos]==tmp2[i]||tmp2[i]=='w')
cnt++;
else
break;
ans=max(ans,cnt);
return ;
}
int main()
{
cin >> len >> s;
for(int i=0; i<len; i++)
help(i);
ans=min(ans,len);
cout << ans;
return 0;
}