def max_cpctf(): import sys n = int(sys.stdin.readline()) s = sys.stdin.readline().strip() s_list = list(s) possible = [] # 首先找出所有可以替换的 CPC 位置 for i in range(len(s_list) - 2): if s_list[i] == 'C' and s_list[i+1] == 'P' and s_list[i+2] == 'C': # 检查替换后是否能在i的位置形成 CPCTF # 只需检查i-4的位置是否是 C-P-C-T if i -4 >=0: if s_list[i-4] == 'C' and s_list[i-3] == 'P' and s_list[i-2] == 'C' and s_list[i-1] == 'T': possible.append(i-4) # 现在,找出所有原始的 CPCTF 结构 original = [] for i in range(len(s_list) -4): if s_list[i] == 'C' and s_list[i+1] == 'P' and s_list[i+2] == 'C' and s_list[i+3] == 'T' and s_list[i+4] == 'F': original.append(i) # 合并所有可能的位置,确保不重叠 all_positions = set(original) for pos in possible: all_positions.add(pos) # 将所有位置排序,并用贪心算法选择尽可能多的不重叠结构 sorted_positions = sorted(all_positions) count = 0 last_end = -1 for pos in sorted_positions: if pos > last_end: count +=1 last_end = pos +4 print(count) max_cpctf()