/*
ID:gwj11391
LANG:C++
TASK:beads
*/
#include<iostream>
#include<algorithm>
#include<string>
#include<fstream>
using namespace std;
int main(){
ifstream fin("beads.in");
ofstream fout("beads.out");
int n, ans = -1;
string s;
fin>>n>>s;
s += s; s += s;
for(int i = n; i < s.size(); i++){
int j1 = i-1, j2 = i, j3, sum = 0;
while(++j1 < s.size() && s[j1] == s[i] || s[j1] == 'w') sum++;
while(--j2 >= 0 && s[j2] == 'w') sum++; j3 = j2;
while(--j3 >= 0 && s[j3] == s[j2] || s[j3] == 'w') sum++;
ans = max(ans, sum);
}
ans>n? fout<<n<<"\n": fout<<ans+1<<"\n";
return 0;
}