#include <bits/stdc++.h>
using namespace std;
char buf[105][105];
int val[105][105];
void add(int x, int y, int coef) {
  for (int i(0), _l((int)(x)-1); i <= _l; ++i)
    for (int j(0), _l((int)(y)-1); j <= _l; ++j) val[i][j] += coef;
}
void solve() {
  int n, m;
  scanf("%d%d\n", &n, &m);
  for (int i(0), _l((int)(n)-1); i <= _l; ++i) gets(buf[i]);
  int res(0);
  for (int i(n - 1); i >= 0; --i)
    for (int j(m - 1); j >= 0; --j) {
      if (buf[i][j] == 'B' && val[i][j] != -1) {
        add(i + 1, j + 1, -1 - val[i][j]);
        ++res;
      } else if (buf[i][j] == 'W' && val[i][j] != 1) {
        add(i + 1, j + 1, 1 - val[i][j]);
        ++res;
      }
    }
  printf("%d\n", res);
}
int main() {
  solve();
  return 0;
}
