N = int(input()) S = list(input()) Q = [] for i in range(N): if S[i] == "F": Q.append("C") Q.append("P") Q.append("C") else: Q.append(S[i]) N = len(Q) ans = 0 stack = ["?", "?", "?", "?", "?", "?"] for i in range(N): if Q[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 stack.append(Q[i]) print(ans)