(defun process-string (input-str) (let ((result-str "") (n (length input-str))) ;; パターンを置換 (dotimes (i n) (setf result-str (concatenate 'string result-str (subseq input-str i (1+ i)))) (when (and (>= (length result-str) 7) (string= (subseq result-str (- (length result-str) 7) (length result-str)) "CPCTCPC")) (setf result-str (subseq result-str 0 (- (length result-str) 3))) (setf result-str (concatenate 'string result-str "F")))) result-str)) (defun count-cpctf (processed-str) (let ((count 0) (len (length processed-str))) (dotimes (i (- len 4)) (when (string= (subseq processed-str i (+ i 5)) "CPCTF") (incf count))) count)) (defun main () (let ((n (read)) (input-str "")) (setf input-str (read-line)) (let ((transformed-string (process-string input-str))) (format t "~A~%" (count-cpctf transformed-string))))) (main)