#include <iostream> #include <vector> #include <cstring> #include <cstdio> using namespace std; int main() { int A[5005]; int n,i; scanf("%d",&n); getchar(); for (i=0;i<n;i++) { char a; scanf("%c",&a); getchar(); if (a=='B') A[i]=0; else A[i]=1; } int k; int f[5005]; int minn=999999999; int record; for (k=1;k<=n;k++) { int ans=0; memset(f,0,sizeof(f)); f[0]=!A[0]; if (f[0]) ans++; int total=f[0]; for (i=1;i<=n-k;i++) { if (i-k>=0) total-=f[i-k]; if (total%2==0) f[i]=!A[i]; else f[i]=A[i]; if (f[i]) ans++; total+=f[i]; } total=0; int flag=0; int temp[5005]; memcpy(temp,A,sizeof(A)); for (i=n-k+1-k;i<=n-k;i++) total+=f[i]; for (i=n-k+1;i<n;i++) { total-=f[i-k]; if (total%2!=0) temp[i]=!temp[i]; if (temp[i]!=1) { flag=1; break; } } if (flag) continue; //printf("k:%d m:%d\n",k,ans); if (ans<minn) { minn=ans; record=k; } else if (ans==minn && k<record) record=k; } printf("%d %d\n",record,minn); }