(defun main (&rest argv) (declare (ignorable argv)) (let* ((kr (read)) (kb (read)) (s1 (read-line)) (cs (make-array 31 :element-type 'integer)) (tmp 0) (ma 0)) (dotimes (i 30) (if (char= #\W (aref s1 i)) (setf (aref cs i) 21) (setf (aref cs i) tmp tmp (1+ tmp)))) (dotimes (i 1048576) (let ((s2 "") (ok 1)) (dotimes (j 30) (when (zerop (logand i (ash 1 (aref cs j)))) (setf s2 (concatenate 'string s2 (string (aref s1 j)))) (when (and (char= #\R (aref s1 j)) (> (length s2) kr) (char= #\R (aref s2 (- (length s2) kr 1)))) (setq ok 0)) (when (and (char= #\B (aref s1 j)) (> (length s2) kb) (char= #\B (aref s2 (- (length s2) kb 1)))) (setq ok 0)))) (unless (zerop ok) (setq ma (max ma (length s2)))))) (format t "~d~%" ma))) (main)