N=int(input()) S=input() T=list(S) for i in range(N-3+1): if S[i:i+3]=="CPC": T[i]="F";T[i+1]="F";T[i+2]="F" T="".join(T) dp=[[0,0] for _ in range(N+1)] for i in range(5,N+1): if S[i-5:i]=="CPCTF": dp[i][0]=dp[i-1][0]+1 else: dp[i][0]=dp[i-1][0] if S[i-5:i-1]=="CPCT" and T[i-1]=="F": dp[i][1]=max(dp[i-1][0]+1,dp[i-1][1]+1) else: dp[i][1]=dp[i-1][1] print(max(dp[N]))