#include <stdio.h>
struct row{
int W, B, R;
} A[50];
enum {w, b, r
};
int ans = 2500;
int sum(int start, int end, int color)
{
int s = 0;
for (int i = start; i <= end; i++)
{
switch(color)
{
case w: s += A[i].R + A[i].B; break;
case b: s += A[i].R + A[i].W; break;
case r: s += A[i].B + A[i].W; break;
}
}
return s;
}
int main(void)
{
int N, M;
scanf("%d %d", &N, &M);
for (int i = 0; i < N; i++)
{
scanf("%*[\n\r]");
for (int j = 0; j < M; j++)
{
char c = getchar();
switch (c)
{
case 'W': A[i].W++; break;
case 'B': A[i].B++; break;
case 'R': A[i].R++; break;
}
}
}
int tmp = 0;
for (int i = 0; i < M - 2; i++)
{
for (int j = i + 1; j < M - 1; j++)
{
tmp = sum(0, i, w) + sum(i + 1, j, b) + sum(j + 1, M, r);
if (tmp < ans)
ans = tmp;
}
}
printf("%d", ans);
return 0;
}