#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 7;
const int N = 2e2 + 10;
char board[N][N];
int cur[N][N];
int a[N];
int main() {
  int n, m;
  cin >> n >> m;
  a['W'] = 1;
  a['B'] = -1;
  for (int i = 0; i < n; i++) cin >> board[i];
  memset((cur), (0), sizeof(cur));
  int ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    for (int j = m - 1; j >= 0; j--) {
      if (a[board[i][j]] != cur[i][j]) {
        ans++;
        int o = cur[i][j] - a[board[i][j]];
        for (int s = i; s >= 0; s--) {
          for (int t = j; t >= 0; t--) {
            cur[s][t] -= o;
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
