import sys input = lambda :sys.stdin.readline()[:-1] ni = lambda :int(input()) na = lambda :list(map(int,input().split())) yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES") no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO") ####################################################################### import re n = ni() s = input() s = (s[::-1].replace("CPC", "A"))[::-1] S = re.split("C|P", s) #print(s) ans = 0 for s in S: s = list(s) for i in range(len(s)): #print(s[i: i+3], ans) if s[i: i+3] == ["A", "T", "A"] or s[i:i+3] == ["A", "T", "F"]: ans += 1 s[i+2] = "F" print(ans)