#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
	int N, M, dp[51][3] = { 0 }, W, B, R, Min=25000;
	char c[51];


	cin >> N >> M;
	for (int i = 0; i < N; i++)
	{
		scanf("%s", &c);

		for (int j = 0; j < M; j++)
		{
			if (c[j] != 'W')
				dp[i][0]++;
			if (c[j] != 'B')
				dp[i][1]++;
			if (c[j] != 'R')
				dp[i][2]++;
		}
	}
	W = 0;
	for (int i = 0; i < N - 2; i++)
	{
		W += dp[i][0];
		B = 0;
		for(int j=i+1;j<N-1;j++)
		{
			B += dp[j][1];
			R = 0;
			for (int k = j + 1; k < N; k++)
			{
				R += dp[k][2];
				
			}
			Min = min(Min, W + B + R);
		}
	}
	cout << Min << endl;
	return 0;
}
