def main(): import sys input = sys.stdin.read().split() n = int(input[0]) s = input[1] # Precompute is_cpc is_cpc = [False] * n for j in range(n - 2): if s[j] == 'C' and s[j+1] == 'P' and s[j+2] == 'C': is_cpc[j] = True # Precompute possible: suffix array possible = [False] * (n + 1) possible[n] = False for k in range(n-1, -1, -1): possible[k] = is_cpc[k] or possible[k+1] # Collect candidates candidates = [] 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': if s[i+4] == 'F' or possible[i+4]: candidates.append(i) # Sort candidates by end position candidates.sort(key=lambda x: x + 4) # Greedily select non-overlapping intervals count = 0 last_end = -1 for start in candidates: end = start + 4 if start > last_end: count += 1 last_end = end print(count) if __name__ == "__main__": main()