N = int(input())
S = input()

stack = []
ans = 0
for i in range(N):
    stack.append(S[i])
    if len(stack) >= 1 and stack[-5:] == ["C","P","C","T","F"]:
        ans += 1
    if len(stack) >= 7 and stack[-7:] == ["C","P","C","T","C","P","C"]:
        for _ in range(3):
            stack.pop()
        stack.append("F")
        ans += 1

print(ans)