#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smin(T &a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
  if (a < b) a = b;
}
char grid[111][111];
int cof[111][111];
int main() {
  int N, M, i, j, res, x, ii, jj;
  scanf("%d%d", &N, &M);
  for (i = 0; i < N; i++) scanf("%s", grid[i]);
  res = x = 0;
  for (i = N - 1; i >= 0; i--) {
    for (j = M - 1; j >= 0; j--) {
      if (grid[i][j] == 'B' && cof[i][j] != -1) {
        res++;
        x = -1 - cof[i][j];
        for (ii = i; ii >= 0; ii--)
          for (jj = j; jj >= 0; jj--) cof[ii][jj] += x;
      }
      if (grid[i][j] == 'W' && cof[i][j] != 1) {
        res++;
        x = 1 - cof[i][j];
        for (ii = i; ii >= 0; ii--)
          for (jj = j; jj >= 0; jj--) cof[ii][jj] += x;
      }
    }
  }
  printf("%d\n", res);
  return 0;
}
