#include <bits/stdc++.h>
using namespace std;
vector<string> v;
int c[100][100];
int f[300];
int main() {
  f['W'] = 1;
  f['B'] = -1;
  int n, m;
  cin >> n >> m;
  v = vector<string>(n);
  for (int i = 0; i < n; ++i) cin >> v[i];
  int ans = 0;
  for (int i = n - 1; i >= 0; --i)
    for (int j = m - 1; j >= 0; --j)
      if (c[i][j] != f[v[i][j]]) {
        ans++;
        int diff = f[v[i][j]] - c[i][j];
        for (int x = 0; x <= i; ++x)
          for (int y = 0; y <= j; ++y) c[x][y] += diff;
      }
  cout << ans;
  return 0;
}
