#include <bits/stdc++.h>
using namespace std;
bool color[201][201] = {0};
int k[201][201] = {0};
int main() {
  int n, m;
  cin >> n >> m;
  string s;
  getline(cin, s);
  for (int i = 0; i < n; i++) {
    getline(cin, s);
    for (int j = 0; j < m; j++) {
      color[i][j] = (s[j] == 'W');
    }
  }
  int q = 0;
  for (int i = n - 1; i >= 0; i--) {
    for (int j = m - 1; j >= 0; j--) {
      if (k[i][j] != (color[i][j] ? 1 : -1)) {
        int need = (color[i][j] ? 1 : -1) - k[i][j];
        q++;
        for (int ti = 0; ti < n; ti++) {
          for (int tj = 0; tj < m; tj++) {
            if (ti <= i && tj <= j) {
              k[ti][tj] += need;
            }
          }
        }
      }
    }
  }
  cout << q << endl;
  return 0;
}
