n = int(input()) s = input().strip() # Initialize counts for 'c', 'o', 'n' in each group (0, 1, 2) counts = [{'c': 0, 'o': 0, 'n': 0} for _ in range(3)] for idx in range(len(s)): group = (idx + 1) % 3 # Determine group based on 1-based index c = s[idx] if c in ['c', 'o', 'n']: counts[group][c] += 1 # Calculate the maximum possible 'con' for each type type0 = min(counts[0]['c'], counts[1]['o'], counts[2]['n'], n - 1) type1 = min(counts[1]['c'], counts[2]['o'], counts[0]['n'], n) type2 = min(counts[2]['c'], counts[0]['o'], counts[1]['n'], n - 1) print(type0 + type1 + type2)