#include <bits/stdc++.h>
using namespace std;
char a[105][105];
long long int M[105][105];
int main() {
  ios_base::sync_with_stdio(0);
  long long int n, m;
  cin >> n >> m;
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < m; j++) cin >> a[i][j];
  }
  long long int ans = 0;
  for (long long int i = n - 1; i >= 0; i--) {
    for (long long int j = m - 1; j >= 0; j--) {
      if (a[i][j] == 'W' and M[i][j] != 1) {
        ++ans;
        for (long long int x = 0; x <= i; x++) {
          for (long long int y = 0; y <= j; y++) {
            M[x][y] += (1 - M[i][j]);
          }
        }
      } else if (a[i][j] == 'B' and M[i][j] != -1) {
        ++ans;
        for (long long int x = 0; x <= i; x++) {
          for (long long int y = 0; y <= j; y++) {
            M[x][y] += (-1 - M[i][j]);
          }
        }
      }
    }
  }
  cout << ans;
  return 0;
}
