#include <bits/stdc++.h>
using namespace std;
const int maxn = 100 + 10;
int n, m;
char data[maxn][maxn];
int val[maxn][maxn];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%s", data[i]);
  }
  memset(val, 0, sizeof(val));
  int cur;
  int ans = 0;
  for (int i = n - 1; i >= 0; --i) {
    cur = 0;
    for (int j = m - 1; j >= 0; --j) {
      cur += val[i][j];
      int goal = (data[i][j] == 'W' ? 1 : -1);
      int dt = goal - cur;
      for (int k = 0; k <= i; ++k) {
        val[k][j] += dt;
      }
      ans += (dt != 0);
      cur += dt;
    }
  }
  printf("%d\n", ans);
  return 0;
}
