#include <bits/stdc++.h>
using namespace std;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
const int mod = 1000000007;
const int root = 1;
const int mm = 105;
char s[mm][mm];
int n, m;
int f[mm][mm];
int ff(char c) {
  if (c == 'W') return 1;
  return -1;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
  int ans = 0;
  for (int i = n; i >= 1; i--) {
    for (int j = m; j >= 1; j--)
      if (f[i][j] != ff(s[i][j])) {
        int tmp = ff(s[i][j]) - f[i][j];
        for (int x = 1; x <= i; x++)
          for (int y = 1; y <= j; y++) f[x][y] += tmp;
        ans++;
      }
  }
  printf("%d\n", ans);
  return 0;
}
