#include <bits/stdc++.h>
using namespace std;
const int LIM = 100;
string f[LIM];
int cnt[LIM][LIM];
void fill(int mi, int mj, int val) {
  for (int i = 0; i <= mi; ++i)
    for (int j = 0; j <= mj; ++j) cnt[i][j] += val;
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) cin >> f[i];
  int ans = 0;
  for (int i = n - 1; i >= 0; --i)
    for (int j = m - 1; j >= 0; --j)
      if (f[i][j] == 'B') {
        if (cnt[i][j] == 0) continue;
        fill(i, j, -cnt[i][j]);
        ++ans;
      } else {
        if (cnt[i][j] == 1) continue;
        fill(i, j, 1 - cnt[i][j]);
        ++ans;
      }
  if (f[n - 1][m - 1] == 'B') ++ans;
  cout << ans;
  return 0;
}
