#include <bits/stdc++.h>
using namespace std;
const int nmax = 105;
int n, m;
vector<string> grid(n);
int added[nmax][nmax];
int ans = 0;
void fix(int r, int c) {
  int expected = grid[r][c] == 'W' ? 1 : -1;
  if (added[r][c] == expected) return;
  ans++;
  int delta = expected - added[r][c];
  for (int i = 0; i <= r; ++i)
    for (int j = 0; j <= c; ++j) added[i][j] += delta;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  grid.resize(n);
  for (int i = 0; i < n; ++i) cin >> grid[i];
  for (int i = n - 1; i >= 0; --i) {
    for (int j = m - 1; j >= 0; --j) {
      fix(i, j);
    }
  }
  cout << ans << '\n';
}
