n=int(input()) st=[] s=input() ans=0 i=0 while i=4 and "".join(st[len(st)-4:])=="CPCT": if s[i]=="F": for i in range(4): st.pop() ans+=1 i+=1 elif i+3<=n and s[i:i+3]=="CPC": for i in range(4): st.pop() ans+=1 i+=3 else: st.append(s[i]) i+=1 else: st.append(s[i]) i+=1 print(ans)