#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int N = 1123456;
int n, m;
char s[120][120];
int dp[120][120];
int ans = 0;
int Ans() {
  memset(dp, 0, sizeof(dp));
  int res = 0;
  for (int i = n - 1; i >= 0; --i) {
    for (int j = m - 1; j >= 0; --j) {
      if (dp[i][j] != s[i][j]) {
        ++res;
        int t = s[i][j] - dp[i][j];
        for (int a = 0; a <= i; ++a) {
          for (int b = 0; b <= j; ++b) {
            dp[a][b] += t;
          }
        }
      }
    }
  }
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  while (cin >> n >> m) {
    for (int i = 0; i < n; ++i) cin >> s[i];
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        if (s[i][j] == 'W')
          s[i][j] = 1;
        else
          s[i][j] = -1;
      }
    }
    cout << Ans() << "\n";
  }
}
