#include <bits/stdc++.h>
int main() {
  int n, m;
  char input[100][101];
  scanf("%d%d", &n, &m);
  int i, j;
  for (i = 0; i < n; i++) scanf("%s", input[i]);
  int trans[100][100] = {0};
  int c = 0;
  for (i = n - 1; i >= 0; i--)
    for (j = m - 1; j >= 0; j--) {
      int tmp;
      if (input[i][j] == 'W')
        tmp = 1 - trans[i][j];
      else
        tmp = -1 - trans[i][j];
      if (tmp == 0) continue;
      int x, y;
      for (x = 0; x <= i; x++)
        for (y = 0; y <= j; y++) trans[x][y] += tmp;
      c++;
    }
  printf("%d\n", c);
  return 0;
}
