N=int(input()) S=input() queue=[] for s in S: queue.append(s) if len(queue)>=4 and queue[-4:]==list("TCPC"): for _ in range(3): queue.pop() queue.append("F") ans=0 N=len(queue) for i in range(N-4): if queue[i:i+5]==list("CPCTF"): ans+=1 print(ans)