(defun ln (n)
  (cons (- (char-int (aref n 0)) 65) (if (char= #\R (aref n 2))
                       t nil)))
(let* ((x (read))
       (y (read))
       (n (1- x))
       (lst (read-line))
       (sp (loop :repeat y :collect(ln (read-line)))) ;char, 右t
       (field (loop :repeat x :collect 1))
       (field-n (loop :repeat 26 :collect '())))
  (defun field-x (q k)
    (push q (elt field-n (- (char-int k) 65))))
  (loop :for s :from 0 :upto (1- (length lst)) :do(field-x s (elt lst s)))
  (defun move (a)
    (let ((lp (elt field-n (car a))))
      (mapcar (lambda (z)
                (princ z)
                (princ (cdr a))
                (if (or (and (cdr a) (= 0 z)) (and (not (cdr a)) (= n z)))
                    (if (cdr a)
                        (progn (setf (elt field (1+ z)) (+ (elt field z) (elt field (1+ z)))) (setf (elt field z) 0))
                        (progn (setf (elt field (1- z)) (+ (elt field z) (elt field (1- z)))) (setf (elt field z) 0)))
                    (setf (elt field z) 0))) lp)))
  (mapcar #'move sp)
  (princ (reduce #'+ field)))