n = int(input()) s = input().strip() # Step 1: Count original CPCTF substrings original_count = 0 for i in range(n - 4): if s[i] == 'C' and s[i+1] == 'P' and s[i+2] == 'C' and s[i+3] == 'T' and s[i+4] == 'F': original_count += 1 # Step 2: Collect all valid CPC positions that can generate CPCTF when converted valid_cpc = [] for i in range(n - 2): if s[i] == 'C' and s[i+1] == 'P' and s[i+2] == 'C': # Check if the previous characters form T followed by CPC if i >= 4: if (s[i-1] == 'T' and s[i-4] == 'C' and s[i-3] == 'P' and s[i-2] == 'C'): valid_cpc.append( (i, i+2) ) # Step 3: Find the maximum non-overlapping intervals using greedy algorithm conversion_count = 0 if valid_cpc: # Sort intervals by their end points valid_cpc.sort(key=lambda x: x[1]) last_end = -1 for start, end in valid_cpc: if start > last_end: conversion_count += 1 last_end = end print(original_count + conversion_count)