#include <bits/stdc++.h>
using namespace std;
int n, m;
long long addX[128];
char c[128][128];
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  int ans = 0;
  for (int y = n - 1; y >= 0; y--) {
    long long cAdd = 0;
    for (int x = m - 1; x >= 0; x--) {
      cAdd += addX[x];
      long long toAdd = 0;
      if (c[y][x] == 'B') {
        toAdd = -cAdd - 1;
      } else {
        toAdd = -cAdd + 1;
      }
      if (toAdd) {
        ans++;
      }
      addX[x] += toAdd;
      cAdd += toAdd;
    }
  }
  cout << ans << "\n";
}
