N, M = gets.split.map &:to_i

W, B, R = (0..2).to_a
color = []
N.times do
  s = gets
  color << [s.count(?W), s.count(?B), s.count(?R)]
end

ans = N * M

(1...(N-1)).each do |t|
  ((t+1)...N).each do |b|
    res = 0
    N.times do |i|
      case i
        when 0...t
          res += M - color[i][W]
        when t...b
          res += M - color[i][B]
        when b...N
          res += M - color[i][R]
      end
    end
    ans = [ans, res].min
  end
end

p ans