#include <bits/stdc++.h>
using namespace std;
const int maxn = 100 + 12;
int a[maxn];
int b[maxn];
string s[maxn];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> s[i];
  int ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    for (int j = m - 1; j >= 0; j--) {
      b[j] = b[j + 1];
      b[j + 1] = 0;
      if (s[i][j] == 'W') {
        if (a[j] + b[j] != 1) ans++;
        b[j] += 1 - a[j] - b[j];
      } else {
        if (a[j] + b[j] != -1) ans++;
        b[j] += -1 - a[j] - b[j];
      }
      a[j] += b[j];
    }
    b[0] = 0;
  }
  cout << ans;
  return 0;
}
