from collections import defaultdict from functools import reduce from numpy import roll def main(): N = int(input()) S = input() CON = "con" buff = [defaultdict(lambda: 0) for _ in range(3)] for i, j in enumerate(S): buff[i%3][j] += 1 cnt = [reduce(min, map(lambda x, y: x[y], roll(buff, i), CON)) for i in range(3)] if cnt == N: print(N) else: print(min(sum(cnt), N-1)) if __name__ == '__main__': main()