#include <bits/stdc++.h>
using namespace std;
inline void OPEN(const string &s) {
  freopen((s + ".in").c_str(), "r", stdin);
  freopen((s + ".out").c_str(), "w", stdout);
}
int n, m;
int val[105][105];
char s[105][105];
int ans;
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < (n); ++i) scanf("%s", s[i]);
  ans = 0;
  memset(val, 0, sizeof(val));
  for (int j = (m - 1); (0) <= j; --j)
    for (int i = (n - 1); (0) <= i; --i) {
      int add;
      int need;
      if (s[i][j] == 'B')
        need = -1;
      else
        need = 1;
      add = need - val[i][j];
      if (add == 0) continue;
      ans++;
      for (int k = (0); k <= (i); ++k)
        for (int l = (0); l <= (j); ++l) val[k][l] += add;
    }
  printf("%d\n", ans);
  return 0;
}
