#include <bits/stdc++.h>
using namespace std;
static const double EPS = 1e-10;
template <typename T, typename S>
vector<T>& operator<<(vector<T>& a, S b) {
  a.push_back(b);
  return a;
}
template <typename T>
void operator>>(vector<T>& a, int b) {
  while (b--)
    if (!a.empty()) a.pop_back();
}
bool isprime(int n) {
  if (n < 2) return false;
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0) return false;
  return true;
}
long long b_pow(long long x, long long n) {
  return n ? b_pow(x * x, n / 2) * (n % 2 ? x : 1) : 1ll;
}
string itos(int n) {
  stringstream ss;
  ss << n;
  return ss.str();
}
int target[111][111];
int now[111][111];
int main() {
  int H, W;
  cin >> H >> W;
  for (int i = 0; i < H; i++)
    for (int j = 0; j < W; j++) {
      char c;
      cin >> c;
      if (c == 'B')
        target[i][j] = -1;
      else
        target[i][j] = 1;
    }
  int ans = 0;
  for (int i = H - 1; i >= 0; i--) {
    for (int j = W - 1; j >= 0; j--) {
      int d = target[i][j] - now[i][j];
      if (d != 0) {
        for (int k = 0; k < i + 1; k++)
          for (int l = 0; l < j + 1; l++) now[k][l] += d;
        ans++;
      }
    }
  }
  cout << ans << endl;
}
