#include <bits/stdc++.h>
using namespace std;
string ft[100];
int bd[100][100];
int mp[128];
int main() {
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  mp['W'] = 1;
  mp['B'] = -1;
  for (int i = 0; i < n; ++i) cin >> ft[i];
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      int p = n - i - 1;
      int q = m - j - 1;
      if (bd[p][q] != mp[ft[p][q]]) {
        int d = mp[ft[p][q]] - bd[p][q];
        for (int x = 0; x <= p; ++x)
          for (int y = 0; y <= q; ++y) bd[x][y] += d;
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
