I,R=input,range N=int(I())*3 S=I() a=0 s="con" for d in R(3): c=[0]*3 for i in R(N):c[i%3]+=S[i]==s[(i+d)%3] a+=min(c+[max(0,(N-a*3-d)//3)]) print(a)