program xxxx;
var z,n,i,m1,m2,y,x,i1,i2,j:longint;
a:array[1..1050] of char;
begin
assign(input,'beads.in');
reset(input);
assign(output,'beads.out');
rewrite(output);
readln(n);
for i:=1 to n do
begin
read(a[i]);
a[i+n]:=a[i];
a[i+n+n]:=a[i];
end;
for i:=1+n to n+n do
begin
m1:=0;m2:=0;x:=0;y:=0;
i1:=i;i2:=i+1;
if a[i+1]<>'w' then
i2:=i+1
else
repeat
begin
inc(i2);
inc(m2);
end
until
a[i2]<>'w';
for j:=0 to n-1 do
begin
if (a[i2+j]='w')or(a[i2+j]=a[i2]) then
inc(m2)
else
begin
if m2>y then
begin
y:=m2;
// m2:=0;
end;
break;
end;
end;
if a[i]<>'w' then
i1:=i
else
repeat
begin
dec(i1);
inc(m1);
end
until
a[i1]<>'w';
for j:=0 to n-1 do
begin
if (a[i1-j]='w')or(a[i1-j]=a[i1]) then
inc(m1)
else
begin
if m1>x then
begin
x:=m1;
//m1:=0;
end;
break;
end;
end;
if x+y>z then
z:=x+y;
end;
if z>n then
write(n)
else
write(z);
close(input);
close(output);
end.