ll@N,a=0;string@S,s="con";rep(d,3){VI c(3);REP(i,3N)c[i%3]+=S[i]==s[(i+d)%3];a+=min(min(c(3)),max(0,N-a-(d+2)/3));}wt(a);