N = int(input()) S = input() i=3 cnt = 0 while i < N-1: c = S[i] if c != "T": i += 1 continue if S[i-3:i] == "CPC": if S[i+1] == "F": cnt += 1 i += 5 if i+3 < N and S[i+1:i+4] == "CPC": cnt += 1 i += 7 else: i += 4 print(cnt)