local bc = string.byte("C", 1)
local bp = string.byte("P", 1)
local bt = string.byte("T", 1)
local bf = string.byte("F", 1)
local n = io.read("*n", "*l")
local s = io.read()

local cnt = 0
local pos = 1
while pos <= n - 4 do
  local found = false
  if s:byte(pos) == bc
  and s:byte(pos + 1) == bp
  and s:byte(pos + 2) == bc
  and s:byte(pos + 3) == bt then
    if s:byte(pos + 4) == bf then
      cnt = cnt + 1
      pos = pos + 5
      found = true
    elseif pos <= n - 6 then
      if s:byte(pos + 4) == bc
      and s:byte(pos + 5) == bp
      and s:byte(pos + 6) == bc then
        cnt = cnt + 1
        pos = pos + 7
        found = true
      end
    end
  end
  if not found then
    pos = pos + 1
  end
end
print(cnt)