import collections N = int(input()) S = list(input()) C = [collections.Counter() for _ in range(3)] for i,c in enumerate(S): C[i%3][c]+=1 v1 = min(C[0]['c'],C[1]['o'],C[2]['n']) v2 = min(N-1,min(C[0]['o'],C[1]['n'],C[2]['c'])) v3 = min(N-1,min(C[0]['n'],C[1]['c'],C[2]['o'])) print(max(v1,v2,v3,min(v1+v2,N-1),min(v2+v3,N-1),min(v3+v1,N-1),min(v1+v2+v3,N-2)))