n = int(input()) s = input() # Step 1: Count existing CPCTF substrings existing_list = [] 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': existing_list.append(i) # Step 2: Find all CPC that are preceded by CPCT and do not overlap with existing CPCTF's first 3 characters candidates = [] for i in range(n - 6): # Check if the current position starts with CPCT if s[i] == 'C' and s[i+1] == 'P' and s[i+2] == 'C' and s[i+3] == 'T': # Check if followed by CPC cpc_start = i + 4 if cpc_start + 2 < n and s[cpc_start] == 'C' and s[cpc_start+1] == 'P' and s[cpc_start+2] == 'C': # Check overlap with existing CPCTF's first 3 characters overlap = False for j in existing_list: existing_start = j existing_end = j + 2 # CPC spans from cpc_start to cpc_start + 2 if not (cpc_start + 2 < existing_start or cpc_start > existing_end): overlap = True break if not overlap: candidates.append((cpc_start + 2, cpc_start)) # (end, start) # Step 3: Greedily select non-overlapping CPC conversions candidates.sort() selected = [] last_end = -1 for end, start in candidates: if start > last_end: selected.append((start, end)) last_end = end # The answer is the existing count plus the number of selected conversions print(len(existing_list) + len(selected))