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