#include <bits/stdc++.h>
using namespace std;
string s[101];
long long pr[101][101];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) cin >> s[i];
  int ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    long long prs = 0;
    for (int j = m - 1; j >= 0; j--) {
      int need = (s[i][j] == 'W') ? 1 : -1;
      prs += pr[i][j];
      if (need != prs) {
        ans++;
        long long val = need - prs;
        for (int t = 0; t <= i; t++) pr[t][j] += val;
        prs += val;
      }
    }
  }
  cout << ans << endl;
  cin.get();
  cin.get();
  return 0;
}
