#include <bits/stdc++.h>
using namespace std;

int w[60], r[60], b[60];

int main()
{
  int n, m;
  cin >> n >> m;
  string flag[n + 1];
  
  for (int i = 1; i <= n; i++) {
    cin >> flag[i];
    for (int j = 0; j < m; j++){
      char c = flag[i][j];
      if (c == 'W') w[i]++;
      else if (c == 'R') r[i]++;
      else if (c == 'B') b[i]++;
    }
  }
  long res = 100000000, ct;
  for (int i = 1; i <= n - 2; i++){
    for (int j = 1; i + j <= n - 1; j++){
      ct = 0;
      for (int k = 0; k < i; k++) ct += m - w[k + 1];
      for (int k = 0; k < j; k++) ct += m - b[i + k + 1];
      for (int k = 0; k < n - i - j; k++) ct += m - r[i + j + k + 1];
      res = min(res, ct);
    }
  }

  cout << res << '\n';
}