#include <bits/stdc++.h>
char map[124][124];
int n, m;
inline int C(char c) {
  if (c == 'B') return -1;
  return 1;
}
int ty, sig;
int ans;
int num[124];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (0), __ = (n); i < __; ++i) scanf("%s", map[i]);
  for (int i = (n - 1), __ = (0); i >= __; --i) {
    sig = 0;
    for (int j = (m - 1), __ = (0); j >= __; --j) {
      ty = C(map[i][j]);
      sig += num[j];
      if (sig == ty) continue;
      ++ans;
      num[j] += (ty - sig);
      sig = ty;
    }
  }
  printf("%d\n", ans);
  return 0;
}
