#include <bits/stdc++.h>
int n, m, i, j, q, dodam, oczekiwana, wynik, war[101];
char t[101][101];
int main() {
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      scanf(" %c", &t[i][j]);
    }
  }
  for (i = n - 1; i >= 0; i--) {
    for (j = m - 1; j >= 0; j--) {
      if (t[i][j] == 'W') {
        oczekiwana = 1;
      } else {
        oczekiwana = -1;
      }
      dodam = oczekiwana - war[j];
      if (dodam != 0) {
        wynik++;
        for (q = 0; q <= j; q++) {
          war[q] += dodam;
        }
      }
    }
  }
  printf("%d\n", wynik);
  return 0;
}
