//16-3 ????????¢??????
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
int main(){
    int N,M;
    cin >> N >> M;
    int W[100] = {};
    int B[100] = {};
    int R[100] = {};
    for(int i=0; i<N; i++){
        string S;
        cin >> S;
        for(int j=0; j<M; j++){
            if(S[j] == 'W'){
                W[i]++;
            }
            else if(S[j] == 'B'){
                B[i]++;
            }
            else if(S[j] == 'R'){
                R[i]++;
            }
        }
    }
    int min1 = 999999;
    for(int i=0; i<N-2; i++){
        int tmp1 = 0;
        for(int j=0; j<i+1; j++){
            tmp1 += B[j] + R[j];
        }
        int min2 = 999999;
        for(int j=i+1; j<N-1; j++){
            int tmp2 = 0;
            for(int k=i+1; k<j+1; k++){
                tmp2 += W[k] + R[k];
            }
            for(int k=j+1; k<N; k++){
                tmp2 += W[k] + B[k];
            }
            if(tmp2 < min2) min2 = tmp2;
        }
        if(tmp1+min2 < min1) min1 = tmp1 + min2;
    }
    cout << min1 << endl;
    return 0;
}
