#include <bits/stdc++.h>
using namespace std;
template <class T>
bool uin(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
const long long P = 1000000000000000003LL;
long long d[101][101];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;
  int N, M;
  cin >> N >> M;
  vector<string> f(N);
  for (int i = 0; i < (int)(N); ++i) cin >> f[i];
  for (int i = 0; i < (int)(N); ++i)
    for (int j = 0; j < (int)(M); ++j) {
      d[i][j] = (f[i][j] == 'W' ? 1 : P - 1);
    }
  int ans = 0;
  for (int i = (int)(N)-1; i >= 0; --i)
    for (int j = (int)(M)-1; j >= 0; --j) {
      if (!d[i][j]) continue;
      ++ans;
      long long z = d[i][j];
      for (int x = 0; x < (int)(i + 1); ++x)
        for (int y = 0; y < (int)(j + 1); ++y) {
          d[x][y] -= z;
          d[x][y] %= P;
        }
    }
  cout << ans << '\n';
  return 0;
}
