#include <bits/stdc++.h>
using namespace std;
char A[101][101];
int now[101][101];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> A[i][j];
  int res = 0;
  for (int i = n - 1; i >= 0; i--) {
    for (int j = m - 1; j >= 0; j--) {
      if (A[i][j] == 'W' && now[i][j] != 1) {
        int diff = 1 - now[i][j];
        for (int x = 0; x <= i; x++)
          for (int y = 0; y <= j; y++) now[x][y] += diff;
        res++;
      }
      if (A[i][j] == 'B' && now[i][j] != -1) {
        int diff = -1 - now[i][j];
        for (int x = 0; x <= i; x++)
          for (int y = 0; y <= j; y++) now[x][y] += diff;
        res++;
      }
    }
  }
  cout << res << '\n';
  return 0;
}
