# Include <stdio. h>
Int N;
Char s [701];
Int beads (INT lx, int RX)
{
Int I;
Int LR = 0, lB = 0, RR = 0, rB = 0;
Int LR1 = 0, lB1 = 0, RR1 = 0, rb1;
For (I = Lx; I <= RX; I ++)
{
If (S [I]! = 'R') & (s [I]! = 'W') LR1 = 1;
Else
If (LR1 = 0)
LR ++;
If (S [I]! = 'B') & (s [I]! = 'W') lB1 = 1;
Else
If (lB1 = 0)
LB ++;
If (LR <lb) LR = LB;
}
For (I = RX; I> = Lx; I --)
{
If (S [I]! = 'R') & (s [I]! = 'W') RR1 = 1;
Else
If (RR1 = 0)
Rr ++;
If (S [I]! = 'B') & (s [I]! = 'W') rb1;
Else
If (Rb1 = 0)
RB ++;
If (RR <Rb) RR = RB;
}
If (LR + RR> N)
Return (N );
Else
Return (LR + RR );
}
Main ()
{
Int I, max = 0, T;
File * In = fopen ("beads. In", "R ");
File * out = fopen ("beads. Out", "W ");
Fscanf (in, "% d \ n", & N );
For (I = 1; I <= N; I ++)
{
Fscanf (in, "% C", & S [I]);
S [n + I] = s [I];
}
For (I = 1; I <= N; I ++)
{
T = beads (I, I + N-1 );
If (T> MAX) max = T;
}
Fprintf (Out, "% d \ n", max );
Fclose (in );
Fclose (out );
Exit (0 );
}