#include <bits/stdc++.h>
using namespace std;
long long int pow_mod(long long int a, long long int b) {
  long long int res = 1;
  while (b) {
    if (b & 1) res = (res * a) % 1000000007;
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return res;
}
char str[105][105];
int ar[105][105];
int main() {
  memset(ar, 0, sizeof(ar));
  int n, m, i, j;
  scanf("%d", &n);
  scanf("%d", &m);
  for (i = 0; i <= n - 1; ++i)
    for (j = 0; j <= m - 1; ++j) cin >> str[i][j];
  int ans = 0;
  while (1) {
    bool flag = false;
    int idx = -1, idy = -1, val = 0;
    for (i = n - 1; i >= 0; --i) {
      for (j = m - 1; j >= 0; --j) {
        if ((str[i][j] == 'W' && ar[i][j] != 1) ||
            (str[i][j] == 'B' && ar[i][j] != -1)) {
          flag = true;
          if (i + j > idx + idy) {
            idx = i;
            idy = j;
            if (str[i][j] == 'W')
              val = 1 - ar[i][j];
            else
              val = -1 - ar[i][j];
          }
        }
      }
    }
    if (!flag) break;
    for (i = 0; i <= idx; ++i)
      for (j = 0; j <= idy; ++j) ar[i][j] += val;
    ans++;
  }
  printf("%d", ans);
  printf("\n");
  return 0;
}
