N=int(input()) S=input() idx=[] for i in range(N): if S[i]=="T": if i<3 and S[i-3:i]!=list("CPC"): continue if i+2<=N and S[i+1]=="F" or i+4<=N and S[i+1:i+4]=="CPC": idx.append(i) le=len(idx) use=[] for i in idx: if use: p=use[-1] if S[p+1]=="C" and i-p<=5: continue use.append(i) ans=len(use) print(ans)