#include <bits/stdc++.h>
using namespace std;
const int MN = 110;
bool g[MN][MN];
int v[MN][MN];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < m; j++) {
      g[i][j] = (s[j] == 'W');
    }
  }
  int s = 0;
  for (int i = n - 1; i >= 0; i--) {
    for (int j = m - 1; j >= 0; j--) {
      int k;
      if (g[i][j])
        k = 1;
      else
        k = -1;
      k -= v[i][j];
      if (!k) continue;
      s++;
      for (int x = i; x >= 0; x--) {
        for (int y = j; y >= 0; y--) {
          v[x][y] += k;
        }
      }
    }
  }
  cout << s << endl;
  return 0;
}
