#include <bits/stdc++.h>
using namespace std;
int n, m, v[105][105], ans;
char s[105][105];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = (0); i < (n); i++) scanf("%s", s[i]);
  for (int i = (n - 1); i >= (0); i--)
    for (int j = (m - 1); j >= (0); j--) {
      int val = s[i][j] == 'W' ? 1 : -1;
      v[i][j] = v[i + 1][j] + v[i][j + 1] - v[i + 1][j + 1];
      if (val != v[i][j]) ans++;
      v[i][j] = val;
    }
  printf("%d\n", ans);
  scanf("\n");
}
