(defun dfs (i j p s res) (if (= i j) (setf (gethash (concatenate 'string p (string (char s i))) res) p) (progn (dfs (1+ i) j (concatenate 'string p (string (char s i))) s res) (dfs i (1- j) (concatenate 'string p (string (char s j))) s res)))) (defun main (&rest argv) (declare (ignorable argv)) (let* ((s (read-line)) (res (make-hash-table :test 'equal))) (dfs 0 (1- (length s)) "" s res) (format t "~D~%" (hash-table-count res)))) (main)