#include <stdio.h>
#include <algorithm>
#include <string.h>

int ans = 123456789;
int blocks[123][3];

int check(int white, int blue, int red){
	int counter = 0;
	for (int a = 0; a < white; a++){
		counter += blocks[a][1] + blocks[a][2];
	}
	for (int a = white; a < blue; a++){
		counter += blocks[a][0] + blocks[a][2];
	}
	for (int a = blue; a < red; a++){
		counter += blocks[a][0] + blocks[a][1];
	}
	return counter;
}

int main(){
	int h, w;
	char buf;
	scanf("%d%d", &h, &w);
	for (int a = 0; a < h; a++){
		for (int b = 0; b < w; b++){
			scanf(" %c", &buf);
			switch (buf){
			case 'W':
				blocks[a][0]++;
				break;
			case 'B':
				blocks[a][1]++;
				break;
			case 'R':
				blocks[a][2]++;
				break;
			}
		}
	}
	for (int a = 1; a <= h - 2; a++){
		for (int b = a + 1; b <= h - 1; b++){
			ans = std::min(ans, check(a, b, h));
		}
	}
	printf("%d\n", ans);
	return 0;
}