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