#include <bits/stdc++.h>
int n, m;
int v[110];
char g[105][105];
int go() {
  memset(v, 0, sizeof v);
  int cnt = 0;
  for (int i = n - 1; i >= 0; i--) {
    for (int j = m - 1; j >= 0; j--) {
      if (g[i][j] == 'W') {
        if (v[j] != 1) cnt++;
        for (int k = 0; k < j + 1; k++) v[k] += (1 - v[j]);
      } else {
        if (v[j] != -1) cnt++;
        for (int k = 0; k < j + 1; k++) v[k] += (-1 - v[j]);
      }
    }
  }
  return cnt;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%s", g[i]);
  printf("%d\n", go());
}
