//https://onlinejudge.u-aizu.ac.jp/challenges/sources/JOI/Prelim/0621?year=2016

#include <bits/stdc++.h>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;

    int cnt[n][3]; //白=0,青=1,赤=2として行毎に色の個数を数える
    memset(cnt, 0, sizeof(cnt));

    map<char, int> mp;
    mp['W'] = 0;
    mp['B'] = 1;
    mp['R'] = 2;

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            char c;
            cin >> c;
            cnt[i][mp[c]]++;
        }
    }

    // 白，青，赤が順にx,y,n-x-y行あるとする
    int ans = 3000;
    for (int x = 1; x <= n - 2; ++x) {
        for (int y = 1; x + y <= n - 1; ++y) {
            int tmp = 0;
            for (int k = 0; k < x; ++k) {
                tmp += m - cnt[k][0];
            }
            for (int k = x; k < x + y; ++k) {
                tmp += m - cnt[k][1];
            }
            for (int k = x + y; k < n; ++k) {
                tmp += m - cnt[k][2];
            }
            ans = min(ans, tmp);
        }
    }

    cout << ans << endl;
    return 0;
}

/*
 * 全検索
 */
