N = int(input()) S = list(input()) ans = 0 stack = ["?", "?", "?", "?", "?", "?"] for i in range(N): if S[i] == "C": if stack[-6:] == ["C", "P", "C", "T", "C", "P"]: ans += 1 stack.pop() stack.pop() stack.pop() stack.pop() stack.pop() stack.pop() continue if S[i] == "F": if stack[-4:] == ["C", "P", "C", "T"]: ans += 1 stack.pop() stack.pop() stack.pop() stack.pop() continue stack.append(S[i]) print(ans)