from collections import defaultdict, deque from heapq import heappush, heappop from itertools import permutations, accumulate import sys import math import bisect def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def IR(n): return [I() for _ in range(n)] def LIR(n): return [LI() for _ in range(n)] sys.setrecursionlimit(1000000) mod = 1000000007 def main(): n = I() s = input() count_c = [0]*3 count_o = [0]*3 count_n = [0]*3 for i,si in enumerate(s): if si == "c": count_c[i%3] += 1 elif si == "o": count_o[i%3] += 1 elif si == "n": count_n[i%3] += 1 c = [count_c, count_o, count_n] ans = 0 for i in range(3): m = float("inf") for j in range(3): m = min(m, c[j][(i+j)%3]) if m == n and i != 0: m = n-1 ans += m print(ans) return if __name__ == "__main__": main()