#include <algorithm>
#include <cstring>
typedef long long ll;
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
const int N=1e6+5;
int main() {
int n;
string s;
cin>>n>>s;
int ans1=0,ans2=0,ans=0;
for(int i=0;i<n;i++){
char key='o';
int count=0,j=i;
while(s[j]=='w'||key=='o'||s[j]==key){
count++;
if(key=='o'&&s[j]!='w'){
key=s[j];
}
j=(j+1)%n;
if(count>=n){
ans1=n;
break;
}
ans1=count;
}
key='o';
count=0,j=n-i-2;
while(s[j]=='w'||key=='o'||s[j]==key){
count++;
if(key=='o'&&s[j]!='w'){
key=s[j];
}
j=(j+n-1)%n;
if(count>=n){
ans2=n;
break;
}
ans2=count;
}
ans=max(ans1+ans2,ans);
}
cout<<min(ans,n);
return 0;
}